File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

type variables

 
patrick van merchtn
Greenhorn
Posts: 9
  • 0
  • 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
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
head first java februari 2005
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • 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
  • 0
  • 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;
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic