wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes type variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "type variables" Watch "type variables" New topic
Author

type variables

patrick van merchtn
Greenhorn

Joined: Apr 04, 2007
Posts: 9
hello, question about type variables chapter 3,

variables must have a type, if you don't specifie the type, what is the type then and is it ok not to specify the type ?

x = 234; p. 51
s = y; p.52
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi,

Which book, which chapter you are talking about? Give full description.


cmbhatt


cmbhatt
patrick van merchtn
Greenhorn

Joined: Apr 04, 2007
Posts: 9
head first java februari 2005
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
No you must specify the type of a variable.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by patrick van merchtn:
...if you don't specifie the type, what is the type then and is it ok not to specify the type ?

x = 234; p. 51
s = y; p.52

You left out some important lines. For example, on page 51, it's...

int x;
x = 234;

Here, the line int x; declares a variable called "x" with a type of int. Then the line x = 234; assigns a literal value to that (previously declared) variable. Declaration and assignment could also be combined in a single line int x = 234;

And on page 52...

int g = 17;
int y = g;
y = y + 10;
short s;
s = y;


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: type variables