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 2 of 2

Thread: Help please with array...

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Help please with array...

    The array nums is a 10 element array of type int that has already been declared and initialized. Write the expression(s) in the box below that prints the sum of the first and second elements of nums to the console:

    (Remember: the first element of an array is at index position 0).


    Heres my code
    print array[0] + array[1]

    it says add a ']' but i dont understand why


  2. #2
    Member
    Join Date
    Mar 2011
    Location
    Earth!
    Posts
    77
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Help please with array...

    Where does "print" come from? Asking because to my knowledge, this is the standard way of printing something to the console in java:
    System.out.print( something );
    Or if you want to print a line:
    System.out.println( something );
    Also, be sure not to forget the ; sign at the end of it.
    Last edited by Kerr; March 21st, 2011 at 04:40 PM.

Similar Threads

  1. Char array to a String array with hex
    By fortune2k in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 20th, 2014, 01:01 PM
  2. prininting out a 4x4 array according to an order by a 1d array
    By fortune2k in forum Collections and Generics
    Replies: 7
    Last Post: November 25th, 2010, 12:54 PM
  3. 2d (4x4) array insdie a 1d array. (Block cipher)
    By fortune2k in forum Collections and Generics
    Replies: 13
    Last Post: November 23rd, 2010, 05:29 PM
  4. [SOLVED] Create new Array from old Array
    By satory in forum Collections and Generics
    Replies: 1
    Last Post: February 24th, 2010, 12:44 PM
  5. Storing an array into an array
    By vluong in forum Collections and Generics
    Replies: 4
    Last Post: September 22nd, 2009, 03:14 PM