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

Thread: keywords

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default keywords

    Hi, could anyone explain what these do..

    lottoticket = new ArrayList<Numbers>();

    qty = numOfLines;

    for(int i=0; i<qty; i++)
           {    
                lottoticket.add(new Numbers());
           }


    for ( int i=0; i<qty; i++ ) 
            {
              //comment
              lottoticket.get(i).print();  // +++++++++++++++++++++++
            }



    thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: keywords

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    What happens when you compile and execute the code?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: keywords

    the code does not execute but i just need an explaination of each one, like what it is

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: keywords

    There are two assignment statements and two for loops.
    Those are VERY BASIC java statements. What is your problem with them? Can you explain?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: keywords

    I want to comment them like this //comment

    but I do not know what to put, could you suggest for each one

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: keywords

    I have no idea what the assignment statements are doing because the posted code does not show what either variable is used for.

    For a description of how for loops work see the tutorial:
    The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)

    For how to use methods:
    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    For ArrayList methods see the API doc:
    Java Platform SE 7
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Can you name the Java keywords?
    By KevinWorkman in forum The Cafe
    Replies: 7
    Last Post: November 19th, 2011, 06:13 PM
  2. keywords
    By crazyjava in forum Java Theory & Questions
    Replies: 2
    Last Post: September 29th, 2010, 12:13 AM
  3. how to extract variables,keywords,operator...
    By Nanda in forum Java Theory & Questions
    Replies: 1
    Last Post: November 12th, 2009, 10:19 PM