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

Thread: literal Loop

  1. #1
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default literal Loop

    what is literal loop?
    I saw this in this URL: Beginner Level


    and inside of this topic here's a sample program:

    public class Sample {
     
        public static void main(String[] args) {
     
            int count = 0;
     
            for (int i = 0x0EF; i <= 0647; i++)
     
            {
                count++;
            }
            System.out.println("The loop looped " + count + " times.");
        }
    }

    question:

    1.) i dont know the value of '0x0ef' , whats that supposed to mean?

    2.) what is literal loop? is it some kind of LOGIC in making a loop? or its just the title of the topic?


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: literal Loop

    1. The value 0x0ef is a hexadecimal number and you can just use your windows calculator to see what it is or just use the code I posted in another thread.

            System.out.println("From hex: " + Integer.decode("0x0ef"));

    2. A literal loop would be a loop that uses the octal or hexadecimal numbers instead of decimal numbers.

    Just have a look at the literal definition on the same page you linked to: Definition for the term: Literal

    // Json

  3. #3
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: literal Loop

    if the hexadecimalas are represented by preceeding charcter '0x' and octal are represented by '0' why is it in java hexadecimals are
    represented by sharp('#')?

    are they similar?
    Last edited by chronoz13; October 10th, 2009 at 10:01 PM.

  4. #4
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: literal Loop

    ... I override the method .decode() .. there's a '0x' preceeding character for hexadecimal conversion...
    Last edited by chronoz13; October 10th, 2009 at 10:06 PM.

Similar Threads

  1. can any one do this in a loop? (for loop)
    By chronoz13 in forum Loops & Control Statements
    Replies: 4
    Last Post: October 4th, 2009, 08:31 PM
  2. For loop tricks
    By helloworld922 in forum Java Programming Tutorials
    Replies: 0
    Last Post: October 4th, 2009, 01:09 AM
  3. JAVA for loop
    By tazjaime in forum Loops & Control Statements
    Replies: 2
    Last Post: August 18th, 2009, 07:43 PM
  4. Why won't this while loop work?
    By trueblue in forum Loops & Control Statements
    Replies: 2
    Last Post: July 17th, 2009, 09:10 AM
  5. [SOLVED] Looping of particular instruction ith times
    By lotus in forum Loops & Control Statements
    Replies: 2
    Last Post: July 12th, 2009, 11:47 PM