Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

type variables

 
patrick van merchtn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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


cmbhatt
 
patrick van merchtn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
head first java februari 2005
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you must specify the type of a variable.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic