Jump to content




Recent Status Updates

View All Updates

Developed by TechBiz Xccelerator
Photo
- - - - -

Local variable x is never read.


  • Please log in to reply
2 replies to this topic

#1 Hunter100

Hunter100

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 292 posts
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly, Bash

Posted 14 March 2010 - 02:53 AM

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?

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
[LEFT]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Variable_Arithmetic {

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][/COLOR][/SIZE][/COLOR][/SIZE][/B] 
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]         public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] main(String[] args) {

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][/COLOR][/SIZE][/COLOR][/SIZE][/B] 
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]                     int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [U]x[/U] = 10;


}

}[/LEFT]
[/SIZE]

I am using Eclipse for whatever it's worth.

Help would be great.
  • 0

#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2,582 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java, PHP

Posted 14 March 2010 - 03:04 AM

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

#3 Hunter100

Hunter100

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 292 posts
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly, Bash

Posted 14 March 2010 - 11:27 PM

Oh Thanks
  • 0




Powered by binpress