aspose file tools*
The moose likes Java in General and the fly likes i cant understand this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "i cant understand this code" Watch "i cant understand this code" New topic
Author

i cant understand this code

alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191


i am new to all this < > consept
i can guess that the new object is called "names"
and that they stack Brian into "names"

can some one explain what <> does??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

I almost closed this post thinking that it was a duplicate of your other post with this exact same subject.
[ March 15, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nhat Nguyen
Greenhorn

Joined: Jan 09, 2008
Posts: 9
you can understand like this:
List<String>: list of string
List<Integer>: list of integer
List<YourBean>: list of YourBean object
...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41525
    
  53
It helps to compare it to the code without the < ... > stuff (that's called Generics, by the way, and you can find an introduction here).



The only difference is that you need to cast the object the get method returns to a String, because a List contains Object instances (while List<String> is guaranteed to contain String instances - which don't need to be cast).

The other differences is that if you use List<String> and ArrayList<String> the compiler can check that only String objects are added to the list. This would not work:

while this does


Ping & DNS - my free Android networking tools app
alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
what is the difference between list and vector??
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
Have you read the links I posted for you a couple of days ago?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i cant understand this code