This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How can I initialize the variable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How can I initialize the variable?" Watch "How can I initialize the variable?" New topic
Author

How can I initialize the variable?

Abeer El-shaer
Greenhorn

Joined: Nov 01, 2012
Posts: 29

--------------------Configuration: <Default>--------------------
C:\cccc.java:184: variable c might not have been initialized
Result.setText(Float .toString(ExpectedValue( c)));
^
Note: C:\cccc.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

Process completed.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

So here is one of your methods:

What do you mean to be passing in to the ExpectedValue() method?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Abeer El-shaer
Greenhorn

Joined: Nov 01, 2012
Posts: 29
fred rosenberger wrote:So here is one of your methods:

What do you mean to be passing in to the ExpectedValue() method?

yes that's right !
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

What do you mean by "Yes, that's right"?

'c' is a local variable to your method. Local variable do not get initialized automatically. So you have to do something like

float c = 0;

or

float c = 234.837;

or

float c = -2323.43432;

But we can't help you more than that, since we have NO idea what c is supposed to represent.
 
jQuery in Action, 2nd edition
 
subject: How can I initialize the variable?
 
Similar Threads
Action Listener
Run Time Error
Displaying an image in a set location in an applet
Check Boxes
How to make the window (JPanel?) bigger in gridbaglayout