Results 1 to 2 of 2

Thread: Array

  1. #1
    phantom06 is offline Member
    Join Date
    Nov 2010
    Posts
    8
    Rep Power
    0

    Default Array

    public CD2(String title, String singer, double price, String category, String discount, String [] track,
    String[]time,int numSong)

    CD2 C = new CD2(arr[0], arr[1], Double.parseDouble(arr[2]), arr[3], arr[4],
    arr[5],arr[6],Integer.parseInt(arr[7]));


    Like in the code above, where i use Double.parseDouble(arr[2]) to change it to double, how to change the arr[5] to array?

  2. #2
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    Array of what? string, character?
    You can use split() or toCharArray() method;
    Java Code:
    String[] arr2 = arr[5].split(",");
    char[] arrChar = arr[5].toCharArray();

Similar Threads

  1. Replies: 23
    Last Post: 09-07-2010, 09:12 PM
  2. Replies: 2
    Last Post: 09-06-2010, 02:03 AM
  3. create a 2d char array from a 1D string array
    By jschmall12 in forum New To Java
    Replies: 1
    Last Post: 04-27-2010, 10:01 PM
  4. Array length and printing out uninitialized array.
    By nicolek808 in forum New To Java
    Replies: 4
    Last Post: 09-10-2009, 10:12 AM
  5. Replies: 1
    Last Post: 03-31-2009, 07:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •