Objects types

Hi,

I came across a piece of code which is as below:

// Retrieving the element at the end of the list

Object element = list.get(list.size()-1);// a

It is claiming here a type which is of "Object" type...what infact really is an object type ? I have till now only seen things like int, string, boolean and so on. I am confused with this.

[368 byte] By [Sangfroida] at [2007-11-26 18:37:13]
# 1
http://java.sun.com/docs/books/tutorial/java/javaOO/index.html~P.S. Strings are objects, so you've seen "object types" before.
yawmarka at 2007-7-9 6:11:18 > top of Java-index,Java Essentials,New To Java...
# 2
There are lots of objects in the existing API. And you can define your own.Go read the manual, and/or some basic tutorials. Learn about the difference between object types and primitive types.
paulcwa at 2007-7-9 6:11:18 > top of Java-index,Java Essentials,New To Java...
# 3
but here they have explicity defined as Object xxx , that is what made me confused...I feel you didn;t understand what i meant to convey...in the code , it has been mentioned explicitly asObject xxx = new ....that we never used to do earlier.
Sangfroida at 2007-7-9 6:11:18 > top of Java-index,Java Essentials,New To Java...
# 4
Every object type extends Object. So you can declare a variable as Object and it works fine, although it's usually not very useful.Read about polymorphism in the tutorials.
paulcwa at 2007-7-9 6:11:18 > top of Java-index,Java Essentials,New To Java...
# 5
Dear Member,A List belongs to Collection. Every collection objects contains data as Object, whenever you are retrieving from the List, Set or Map, you have to type case it.
DebadattaMishraa at 2007-7-9 6:11:18 > top of Java-index,Java Essentials,New To Java...
# 6

> A List belongs to Collection. Every collection

> objects contains data as Object, whenever you are

> retrieving from the List, Set or Map, you have to

> type case it.

Until the J2SE version 5:

import java.util.*;

public class Example {

public static void main(String[] args) {

Map<String, String> m = new HashMap<String,String>();

m.put("hello", "world");

String value = m.get("hello");

System.out.println(value);

}

}

DrLaszloJamfa at 2007-7-9 6:11:18 > top of Java-index,Java Essentials,New To Java...