Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: stumped......

  1. #21
    trueblue is offline Member
    Join Date
    Mar 2009
    Posts
    57
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    As with other arrays, you can simply declare the values in it, and avoid explicitly declaring a size:

    Java Code:
    char[] aChar = new char[] {/*Put your individual characters in here in single quotes separated by commas*/};
    so if my code is correct does the above code fit into the constructor statement or are there two separate statements required: one to declare and initialise the char array and one to declare and initialise an instance of the class?

  2. #22
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    Quote Originally Posted by trueblue View Post
    so if my code is correct does the above code fit into the constructor statement or are there two separate statements required: one to declare and initialise the char array and one to declare and initialise an instance of the class?
    You could put it straight into the constructor call (new SimpleString(new char[]{...})), but it'd probably look less messy creating an object in the line beforehand, especially if you have a lot to go into the array.

Page 2 of 2 FirstFirst 12

Posting Permissions

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