Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Use char[][] instead of string[].

  1. #1
    Junior Member
    Join Date
    May 2021
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Use char[][] instead of string[].

    Hello, is there a way to use char[][] instead of using the string[] type.

    String[] mylist1 = {"apple", "orange", "pear"};
    char[][] mylist2 = new char[4][128];

  2. #2
    Member
    Join Date
    Apr 2020
    Posts
    147
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Re: Use char[][] instead of string[].

    If you want to use the word apple as char and not a string you have use ' ' and not " ".

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Use char[][] instead of string[].

    The String class has a method that will copy the contents of a String into a char array.
    Read the API doc.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Sequences (convert char[] to String) [Replacing String with Character]
    By tpolwort in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 25th, 2013, 02:56 PM
  2. Replies: 3
    Last Post: March 23rd, 2013, 07:20 PM
  3. Get int value from char, char pulled from String
    By Andrew Red in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 4th, 2013, 10:04 AM
  4. string-int-char
    By mdhmdh100 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 25th, 2012, 01:35 PM
  5. [SOLVED] String Matcher finding only char not a whole string
    By Kakashi in forum What's Wrong With My Code?
    Replies: 11
    Last Post: February 18th, 2011, 09:58 AM