Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I initialize the variable?

 
Abeer El-shaer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

--------------------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
Posts: 12127
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So here is one of your methods:

What do you mean to be passing in to the ExpectedValue() method?
 
Abeer El-shaer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12127
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic