Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:44:34+00:00 2026-06-08T13:44:34+00:00

The following statement doesn’t work in Java, but works in C: char c[] =

  • 0

The following statement doesn’t work in Java, but works in C:

char c[] = "abcdefghijklmn";

What’s wrong?

Does the char array can only be initialized as following?

char c[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:44:36+00:00Added an answer on June 8, 2026 at 1:44 pm

    You could use

    char c[] = "abcdefghijklmn".toCharArray();
    

    if you don’t mind creating an unnecessary String.

    Unlike in C, Strings are objects, and not just arrays of characters.

    That said, it’s quite rare to use char arrays directly. Are you sure you don’t want a String instead?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does the following statement holds for any double (Java primitive double precision IEEE-754) except
In the following SQL statement, SQLite sorts correctly but MySQL does not: However, if
The following statement doesn't work: dist_include_DATA = someheaders.h which cause error: Makefile.am:8: `includedir' is
What does the following Javascript statement do to a ? a >>>= b;
(XCode 4.3) Why does the following crash at the NSLog statement with EXC_BAD_ACCESS? BOOL
In the following statement: java.lang.Object.wait(Object.java:???)[Native Method] - waiting on <0x6ab0eb48> (a coldfusion.runtime.RWLock) coldfusion.runtime.RWLock.waitForLock(RWLock.java:154) What
I have a problem with following statement trace(Number(1/2)) //output NaN but trace(Number(1.2)) //output 1.2
I have the following statement in my code: if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) but
The following statement BACKUP LOG [AMS_Prod_log] WITH TRUNCATE_ONLY works fine in SQL Server 2005
I'm new to RoR; I want create the following statement. I've an array; I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.