Results 1 to 12 of 12

Thread: java problem

  1. #1
    Zunon is offline Member
    Join Date
    Jul 2012
    Posts
    12
    Rep Power
    0

    Unhappy java problem

    SOLVED REQUESTING LOCK


    hi, im zunon im 13 yrs old and im learning java, while reading the book :
    Java: a beginners guide fifth edition i stumbled upon the same error twice:
    when I copy the code shown in the book and try to compile them I get an error in javac but when I copy and paste the exact same code from the file from the website it compiles and runs perfectly, I tried to spot and eliminate every difference I find in the 2 texts can you help me and find the differences I couldn't find?

    My version of the code:

    Java Code:
    /*
       This program illustrates the differences
       between int and double.
      
       Call this file Example3.java
    */
    class Example3 {
      public static void main(String args[]) {
        int var;  // this declares an int variable
    	double x; // this declares a floating-point variable
    	
    	var = 10; // assign var the value 10
    	
    	x = 10.0; // assign x the value 10.0
    	
    	System.out.printIn("Original value of var: " + var);
    	System.out.printIn("Original value of x: " + x);
    	
    	System.out.printIn(); // print a blank line
    	
    	// now, divide both by 4
    	var = var / 4;
    	x = x / 4;
    	
    	System.out.printIn("var after division: " + var);
    	System.out.printIn("x after division: " + x);
      }
    }
    the supplied one from the book:
    Java Code:
    /*  
       This program illustrates the differences 
       between int and double. 
     
       Call this file Example3.java. 
    */  
    class Example3 {  
      public static void main(String args[]) {  
        int var;  // this declares an int variable 
        double x; // this declares a floating-point variable 
     
        var = 10; // assign var the value 10 
        
        x = 10.0; // assign x the value 10.0 
     
        System.out.println("Original value of var: " + var); 
        System.out.println("Original value of x: " + x); 
     
        System.out.println(); // print a blank line 
     
        // now, divide both by 4 
        var = var / 4;  
        x = x / 4; 
     
        System.out.println("var after division: " + var); 
        System.out.println("x after division: " + x); 
      }  
    }
    Last edited by Zunon; 07-19-2012 at 12:13 PM. Reason: add code tags

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,777
    Blog Entries
    7
    Rep Power
    21

    Default Re: java problem

    What did your compiler complain about? (copy the error message verbatim here please).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Zunon is offline Member
    Join Date
    Jul 2012
    Posts
    12
    Rep Power
    0

    Default Re: java problem

    Example3.java:16: error: cannot find symbol
    System.out.printIn("Original value of var: " + var);
    ^
    symbol: method printIn(String)
    location: variable out of type PrintStream
    Example3.java:17: error: cannot find symbol
    System.out.printIn("Original value of x: " + x);
    ^
    symbol: method printIn(String)
    location: variable out of type PrintStream
    Example3.java:19: error: cannot find symbol
    System.out.printIn(); // print a blank line
    ^
    symbol: method printIn()
    location: variable out of type PrintStream
    Example3.java:25: error: cannot find symbol
    System.out.printIn("var after division: " + var);
    ^
    symbol: method printIn(String)
    location: variable out of type PrintStream
    Example3.java:26: error: cannot find symbol
    System.out.printIn("x after division: " + x);
    ^
    symbol: method printIn(String)
    location: variable out of type PrintStream
    5 errors

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: java problem

    And please use [code] tags [/code] when posting code.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: java problem

    That's a lower case 'L' in println, not an 'I'.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    Zunon is offline Member
    Join Date
    Jul 2012
    Posts
    12
    Rep Power
    0

    Default Re: java problem

    no I'm pretty sure that's an I using np++ I can see the difference between I and l

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,777
    Blog Entries
    7
    Rep Power
    21

    Default Re: java problem

    Turn on the light above your computer screen and check again.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Zunon is offline Member
    Join Date
    Jul 2012
    Posts
    12
    Rep Power
    0

    Default Re: java problem

    Quote Originally Posted by JosAH View Post
    Turn on the light above your computer screen and check again.

    kind regards,

    Jos
    it's already clear, it's midday and I triple-checked and I'm pretty sure that's an 'I'
    thank you - Zunon

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,777
    Blog Entries
    7
    Rep Power
    21

    Default Re: java problem

    Quote Originally Posted by Zunon View Post
    it's already clear, it's midday and I triple-checked and I'm pretty sure that's an 'I'
    thank you - Zunon
    Just for the fun of it, change the capital 'I' to a lower case 'l' and see for yourself.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    Zunon is offline Member
    Join Date
    Jul 2012
    Posts
    12
    Rep Power
    0

    Wink Re: java problem

    Quote Originally Posted by JosAH View Post
    Just for the fun of it, change the capital 'I' to a lower case 'l' and see for yourself.

    kind regards,

    Jos
    OH ... I thought it should be with an I not an L, I didn't know that ... Sorry for arguing, I'm too stupid to have seen that.


    Thank you alot for showing me

  11. #11
    Zunon is offline Member
    Join Date
    Jul 2012
    Posts
    12
    Rep Power
    0

    Default Re: java problem

    I just downloaded Eclipse and I see that PrintIn is wrong but Println in right... but what does the Ln part mean? Requesting lock for thread

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

    Default Re: java problem

    It's shorthand for "line".
    So "print line".

    Don't ask me why they shortened it, but I suspect it's a C++ stdlib throwback.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Java GUI problem
    By Rezan in forum AWT / Swing
    Replies: 0
    Last Post: 04-09-2012, 12:23 AM
  2. Replies: 4
    Last Post: 03-16-2012, 12:29 PM
  3. Small problem with problem with Java, C++ parse program.
    By dragstang86 in forum New To Java
    Replies: 4
    Last Post: 10-30-2011, 04:43 AM
  4. Problem Display Jmenubar Java Se6 u23 versus Java SE6 u22
    By Ravanelly in forum Advanced Java
    Replies: 0
    Last Post: 01-07-2011, 10:36 AM
  5. Java Problem. Need Help!
    By bob101 in forum New To Java
    Replies: 6
    Last Post: 03-19-2009, 05:34 AM

Posting Permissions

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