aspose file tools*
The moose likes Beginning Java and the fly likes Retrieving a value .. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Retrieving a value .." Watch "Retrieving a value .." New topic
Author

Retrieving a value ..

podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
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

Joined: Nov 28, 2007
Posts: 215

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

Joined: Aug 05, 2005
Posts: 3169
    
  10
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.


Joanne
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

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

Joined: Jul 08, 2003
Posts: 24168
    
  30

Actually, I suspect what the original poster is wanting to be taught is the notion of a return value:



[Jess in Action][AskingGoodQuestions]
podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
hey THANKS A LOT .. my doubts has gone one more time
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving a value ..
 
Similar Threads
Can you explain me how the static works in this example?
boolean & Boolean - interchanable (where & where not)?
IS this question good? why
I am a real JAVA beginner, please take a look at this code.
Operator Precedence