Re: Integer vs. Number vs int
Re: Integer vs. Number vs int
- Subject: Re: Integer vs. Number vs int
- From: Kieran Kelleher <email@hidden>
- Date: Sat, 29 Nov 2003 00:23:01 -0500
Drew,
If you are beginning Java and want to get off on the right foot with OO
programming in Java, I would recommend you go through the following
book first:
Beginning Java Objects by Jacquie Barker (available at Amazon or other
major online stores)
.......... I have this and the Thinking in Java by Bruce Eckel book
that was also recommended to you ..... and for beginners the Beginning
Java Objects is an absolutely a great book that can cover a lot of
essential fundamentals ground in a short time. It introduces Java
basics, then really explains Objected Oriented topics using easy to
understand illustrations and finally gets into OO development using
Java. The Bruce Eckel book is totally comprehensive but it is a very
big book and heavy going for the beginner IMHO .... better as a second
book I think.
Also don't forget the Apple "crash course" in Java which is very short
and available online at:
http://developer.apple.com/documentation/WebObjects/JavaForWODev/
JavaForWODev.pdf
- K
____________________________________
OS X 10.3.1 / WO 5.2.2 / MySQL 4.0.16
On Nov 27, 2003, at 10:44 AM, Pierre Bernard wrote:
BTW,
there is a major difference between those two lines of code:
public int tempNum = 1;
public String tempString = "abc";
The first one creates a primitive type. The second one creates an
object: an instance of java.lang.String. Indeed "abc" is a handy
shortcut to create a String object. It might be confusing at first
sight as it makes String look like it was a primitive type. But it
sure is much more convenient than new String(new char[] { 'a', 'b',
'c' }), isn't it?
Pierre
-----Original Message-----
From: Pierre Bernard
Sent: Thursday, November 27, 2003 4:02 PM
To: Drew Thoeni; email@hidden
Subject: RE: Integer vs. Number vs int
Hi!
The number 1 is an int. int is a primitive type. Other primitive types
are: long, double, float, char, boolean, ...
Along those primitive types Java has corresponding wrapper objects
that provide a ceratin number of utility methods. The main reason for
their existence is for the programmer to be able to handle and store
such types the same way as any other Java object. E.g. the only way to
store a number in a collection is by wrapping it in such an object.
Examples are Integer, Long, Char, Boolean ...
Your variable is a reference to an object of type Number. Number is an
abstract superclass of the various wrapper object that represent
numbers. You may assign any instance of a concrete subclass of Number
to your variable. Integer is such a class. new Integer(1) is a
matching object.
For further reading I suggest Bruce Eckel's Thinking in Java. A link
to it is available from my web page:
http://homepage.mac.com/I_love_my/webobjects.html
Pierre.
-----Original Message-----
From: Drew Thoeni [mailto:email@hidden]
Sent: Thursday, November 27, 2003 12:09 PM
To: email@hidden
Subject: Integer vs. Number vs int
I am trying to put a numeric value into an Number object using:
public Number tempNum = 1;
But I get "incompatible types" on compile.
I'm new to Java but this seems analogous to the Java
public String tempString = "abc";
Which compiles fine.
I get the same "incompatible types" with:
public Integer tempNum = 1;
What am I missing?
Drew
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.