wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes newbie question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "newbie question" Watch "newbie question" New topic
Author

newbie question

Papa Miller
Greenhorn

Joined: Sep 22, 2010
Posts: 11
in the following example:

int a = 3;
double b;
b=a<=10?0.25:1.8;

I don't understand what the second line of code (double b) is doing? Is it doubling the value of 3, or does it have something to do with the data type, and b is assumed to be consecutive to 3?
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
It is declaring a variable b as type double, much like the first line of code declares the variable a as type int. The difference is that the variable a is initialized to the value 3, whereas the variable b is not initialized until line 3.
Papa Miller
Greenhorn

Joined: Sep 22, 2010
Posts: 11
Tom, thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

I'm betting you'd enjoy reading this article!


[Jess in Action][AskingGoodQuestions]
Papa Miller
Greenhorn

Joined: Sep 22, 2010
Posts: 11
Ernest Friedman-Hill wrote:I'm betting you'd enjoy reading this article!


thanks for the link, Sherriff!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: newbie question