Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Retrieving a value ..

 
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 !
 
  • 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 ]
 
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 VI Editor Linux
  • 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.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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
Boost this thread!