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]

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.
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.
> 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);
}
}