Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving a value ..

 
podonga poron
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class example{

public static void method(){
boolean value=false;
}

public static void main(String Args[]){
//how can i get the boolean value here ?
}
}

thanks !
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by podonga poron:
public class example{

public static void method(){
boolean value=false;
}

public static void main(String Args[]){
//how can i get the boolean value here ?
}
}

thanks !


You are creating a local variable inside method whose visiblity is limited inside the method itself.Change you code like this


[ May 13, 2008: Message edited by: Balasubramanian Chandrasekaran ]
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balasubramanian
To avoid confusing the beginner's even more, it's probably a good idea to try compiling your examples before you post them.
You can't access instance variables from static methods with creating an object.
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joanne Neal:
Balasubramanian
To avoid confusing the beginner's even more, it's probably a good idea to try compiling your examples before you post them.
You can't access instance variables from static methods with creating an object.


Sorry Joanne, i just typed it here itself without looking onto that point.That s a good point.

the variable declaration must be


it's probably a good idea to try compiling your examples before you post them

ya i will surely do this one.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I suspect what the original poster is wanting to be taught is the notion of a return value:

 
podonga poron
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey THANKS A LOT .. my doubts has gone one more time
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic