Closed Thread
Results 1 to 3 of 3

Thread: Local variable x is never read.

  1. #1
    Hunter100 is offline Programming Professional
    Join Date
    Feb 2010
    Location
    Australia
    Posts
    289
    Rep Power
    0

    Question Local variable x is never read.

    Hello all,

    I was watching a Java tutorial on YouTube about variable arithmetic. So I thought I'd make a simple programm to take two variables and do arithmetic on them. So I declare an int variable x. Then this happens:

    I hover the mouse and it says "Local variable x is never read". What is this?

    Code:
    
    
    public
    class Variable_Arithmetic { publicstaticvoid main(String[] args) { int x = 10; } }
    I am using Eclipse for whatever it's worth.

    Help would be great.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    May 2009
    Location
    Belgium
    Posts
    1,879
    Rep Power
    24

    Re: Local variable x is never read.

    It's just a 'warning' probably because you declare x. But you don't do anything useful with it. If below you say
    Code:
    System.out.println(x);
    then it's most likely solved as eclipse notices that x is now used and useful in some way.

  4. #3
    Hunter100 is offline Programming Professional
    Join Date
    Feb 2010
    Location
    Australia
    Posts
    289
    Rep Power
    0

    Re: Local variable x is never read.

    Oh Thanks

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 11-26-2010, 08:53 AM
  2. Local variable is never read
    By corsica in forum Java Help
    Replies: 4
    Last Post: 05-12-2010, 04:21 AM
  3. use of unassigned local variable
    By Siten0308 in forum C# Programming
    Replies: 3
    Last Post: 01-13-2009, 09:14 AM
  4. Read input into a variable
    By TcM in forum C# Programming
    Replies: 10
    Last Post: 02-04-2008, 07:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

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