And to reiterate what helloworld922 said, you could also do something like this:
ArrayList<Number> numbers = new ArrayList<Number>();
Integer i = new Integer(1);
Double d = new Double(3.14);...
Type: Posts; User: KevinWorkman
And to reiterate what helloworld922 said, you could also do something like this:
ArrayList<Number> numbers = new ArrayList<Number>();
Integer i = new Integer(1);
Double d = new Double(3.14);...
Sort of. If you don't use a getter or some other function (like in my example), then println() is going to look at the toString() method to figure out what it should print.
Not necessarily. For...
I suppose that's one way to do it. Or you could just use the getter functions in Point to print the values out yourself.
For example, say I have a Rectangle r, and I want to print its width. I...
The API is your friend.
Java Platform SE 6 (that's a link, click it)
Because that's what's returned by Point.toString(), which is probably just using Object's toString().
What did you expect to print out? Java doesn't automatically know how to format a String...
No. Your points ArrayList only accepts Doubles. A Point is not a Double, it contains Doubles (or doubles). Trying to add a Point to an ArrayList of Doubles won't work. Perhaps you want an ArrayList...
2.7 is a double. 2.7f is a float. (float)2.7 is also a float.