• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

static Boolean getBoolean();

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a problem understanding in which context boolean getBoolean()should be used.The manual I am learning from and the API states that the method returns true if the system property named by the argument exists and is equal to the string "true";I have written a very simple program trying to get the method to return true , but cannot get it to this state.Obviously I am missing the point in the explanation in the APIie what is meant by "system property",,would someone be kind enough to explain , please.
here`s the simple BoolGetBool class:-


thankyou.
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try and run the program below for 'true' value,

Also try and understand the API below,
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html
and get back if you have doubts.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A "system property" is a variable that is given a value by the Operating System or the Java Virtual Machine. Just like variables in your program, system poperties have a name as well as the assigned value. I don't know any boolean properties that I could use for an example.

However, it looks like what you really want to use is the Boolean.parseBoolean() method instead. This method will take the String argument and return true if its argument is equal to the String "true", ignoring case.

Notice how the arguments to these two methods are interpreted. The argument to getBoolean() is the NAME of a system property. This name is similar to a variable name in your Java program. Also, this name probably isn't the word "true". On the other hand, the argument to the parseBoolean() method is checked for equality with the word "true".

I hope this clears up the confusion here. Please let us know if you need more help.

Layne
 
Daniel .J.Hyslop
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi layne;
At the moment I am practising and experimenting using methods within the wrapper classes and the more system defined common classes within the API. I am accessing each of these classes and just trying to understand the mechanics of their methods by constucting my own classes and using their methods one class at a time,(the one thing that still puzzles me a bit is the use of static) I used the valueOf(String s) method as my first example in the Boolean class and measured that against the outcome of using getBoolean(String name),I did try quite a few variations of passing arguments to the later method but to no avail,obviously as you explained those arguments were not system orientated.Do command line arguments hold system property elements that would work,I`ll give it a go anyway and see,it won`t hurt to see what happens.
thanks for your reply ,if you would like to add to anything I`ve just said then please explain away.
reply
    Bookmark Topic Watch Topic
  • New Topic