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

Thread: PLease help, I am trying to...

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PLease help, I am trying to...

    Declare an array named a of * ten* elements of type int and initialize the elements (starting with the first) to the values 10 , 20 , ..., 100 respectively.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: PLease help, I am trying to...

    What have you tried? Where are you stuck?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLease help, I am trying to...

    int a [10] = {10,20,30,40,50,60,70,80,90,100};

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: PLease help, I am trying to...

    And what does that do?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Nov 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLease help, I am trying to...

    It returns an error.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: PLease help, I am trying to...

    What is the error?

    Recommended reading: Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    Like we said in your other post, the basic tutorials are your best friend.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLease help, I am trying to...

    Not when I am trying to complete an assignment. Thanks for your help.

  8. #8
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: PLease help, I am trying to...

    Especially when you're trying to complete an assignment.

    As a side note, you can either initialize an array to a given size or to what it starts with, not both at the same time.

  9. #9
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: PLease help, I am trying to...

    Quote Originally Posted by SandeeBee View Post
    Not when I am trying to complete an assignment. Thanks for your help.
    This doesn't make any sense. How do you expect to complete the assignment without looking at the tutorials? For that matter, how is getting help from other people allowed if looking through the tutorials yourself is not?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #10
    Junior Member
    Join Date
    Nov 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLease help, I am trying to...

    Because looking at the tuorial is more of a foreign language than being on this board. I do not understand any of it. I checked the tutorials before joining this site. This was my last resort.

  11. #11
    Member
    Join Date
    Oct 2011
    Posts
    35
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: PLease help, I am trying to...

    take out the 10 in side the brackets and it should be fine

  12. #12
    Junior Member
    Join Date
    Nov 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLease help, I am trying to...

    Thanks so much, if you get a chance , could you send me a link to a java beginners site or a java for dummies website?

  13. #13
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: PLease help, I am trying to...


  14. #14
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: PLease help, I am trying to...

    Assignments usually means time-pressure. Taking that into account, here is the answer:

    int[] a = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};

    That makes an array of ten int-numbers. 10 to 100.

    If you want to test it out for yourself, this little code will print out everything:

    for (int i = 0; i < a.length; i++)
    System.out.println(a[i]);

    Hope it helped.

    EDIT (You got the answer already, but i wanted to illustrate it for clarity^^)

  15. #15
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: PLease help, I am trying to...

    Quote Originally Posted by ViRAL View Post
    Assignments usually means time-pressure. Taking that into account, here is the answer:

    int[] a = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};

    That makes an array of ten int-numbers. 10 to 100.

    If you want to test it out for yourself, this little code will print out everything:

    for (int i = 0; i < a.length; i++)
    System.out.println(a[i]);

    Hope it helped.

    EDIT (You got the answer already, but i wanted to illustrate it for clarity^^)
    Can't he read all this from internet???
    We are not here to spoon feed but to teach others to learn from the mistakes on their own. Appreciate your hep but don't spoon feed

  16. The Following 2 Users Say Thank You to Mr.777 For This Useful Post:

    copeg (November 13th, 2011), KevinWorkman (November 13th, 2011)

  17. #16
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: PLease help, I am trying to...

    Given the fact that the tutorials solve a problem which is identical to yours but a factor of 10 out, makes me wonder whether your assignment was to actually read the documentation.

    If that is a foreign language to you, then parhaps you should re-consider programming. All programming relies around the ablility to read documentation/man pages on a subject you do not know and make sense of it.

    Trying reading just over half way down the page linked above by Kevin

  18. The Following User Says Thank You to Freaky Chris For This Useful Post:

    KevinWorkman (November 13th, 2011)