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

Thread: Getting 'Variable out of type PrintStream ', unable to figure out why please help

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Getting 'Variable out of type PrintStream ', unable to figure out why please help

    Hi,

    I am trying to understand Life time of a variable by writing a below program. But unable to compile it as it is throwing some error. please go through below for code snippet and error as follows,

    // Understanding Lifetime of a variable.
     
    class LifeTime {
     
    public static void main(String args[]) {
     
    int x;
     
    for(x = 0; x <3 ; x++) {
     
    int y = -1; // y is initialized each time block is entered
     
    System.out.Println("y is: " + y); // this always prints -1
     
    y = 100;
     
    System.out.println("y is now: " + y); 
            }
     
         }
     
    }

    I would appreciate your help on fixing this error.

    Please refer to the print screen attached 'LifeTime.jpeg' to this thread to know more about error.

    Thanks in advance,
    Java Beginner
    Attached Images Attached Images


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Getting 'Variable out of type PrintStream ', unable to figure out why please help

    Avoid posting pictures, screenshots, etc., if at all possible. They're just too hard to read - but not impossible. You should be able to bring up a menu that allows copying all or selected text by right clicking or something.

    You have a typo which is clearly indicated by the error message. Java is case sensitive.

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting 'Variable out of type PrintStream ', unable to figure out why please help

    Got it! It was 'P' instead of 'p' Thanks very much....going forward i will just add the error details, not the screenshot...thanks once again.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Getting 'Variable out of type PrintStream ', unable to figure out why please help

    You're welcome.

  5. #5
    Junior Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting 'Variable out of type PrintStream ', unable to figure out why please help

    Hi,

    i have one more question. When i was searching fix for the error, someone has suggested that, if we have either Netbean or Eclipse IDE installed, it would be easy to catch these type of errors. Hence, i have installed Eclipse IDE and tried to run the some of my tiny Java programs. I am able to import the Java program into IDE but unable to run it as it is throwing some error.
    Please help me to understand, IDE is meant for running Java as a project or even i can run small programs too.....
    By the way i like the way you guys teaches, by not giving direct answer, instead prompting the learners to find a solution on their own by giving a clue.....

  6. #6
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Getting 'Variable out of type PrintStream ', unable to figure out why please help

    An IDE is an Integrated Development Environment - it is software
    that houses an editor to write source code, a compiler to translate
    the code into machine language, and a debugger to help you step
    in and out of the code. The size of the source file you write or import
    to the editor makes little difference. As long as the syntax is correct,
    it will execute.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  7. #7
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Getting 'Variable out of type PrintStream ', unable to figure out why please help

    I am able to import the Java program into IDE but unable to run it as it is throwing some error.
    Post the complete and exact text of error message you want help with. We can't help you fix "some error."

Similar Threads

  1. Replies: 4
    Last Post: March 29th, 2014, 07:49 PM
  2. I Need Assistance With Using a Bool Type Variable
    By Lacie1013 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 24th, 2013, 03:35 PM
  3. Help with making classes as a variable type!
    By Kranti1992 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 22nd, 2012, 01:05 AM
  4. Variable Type-Checking
    By richip in forum Collections and Generics
    Replies: 7
    Last Post: March 17th, 2011, 06:25 PM
  5. Not sure what type of variable to use.
    By mjpam in forum Java Theory & Questions
    Replies: 13
    Last Post: July 13th, 2010, 08:58 PM