So code that looked like this before:
List
programmingLanguages.add("Java");
programmingLanguages.add("C++");
programmingLanguages.add("Ruby");
Now looks like this:
List
"Java", "C++", "Ruby");
With all the focus on type safety, it refreshing to see an interesting use for Generics. Is this just and edge case or are there any other techniques that you’ve discovered and would like to share.
Threaded replies
· Concise code with Generics and varargs by Kirk Pepperdine on Wed Nov 30 05:42:24 EST 2005
· Concise code with Generics and varargs by Geert Bevin on Wed Nov 30 06:04:10 EST 2005
· Concise code with Generics and varargs by Mileta Cekovic on Thu Dec 01 10:58:04 EST 2005
· But I get a warning by Janos Mucsi on Fri Mar 02 17:39:32 EST 2007
· Concise code with Generics and varargs by Erik van Oosten on Wed Nov 30 11:17:20 EST 2005
· Concise code with Generics and varargs by Joshua White on Thu Dec 01 14:04:47 EST 2005
· Concise code with Generics and varargs by Werner Schulz on Thu Dec 01 20:12:21 EST 2005
· Concise code with Generics and varargs by D S on Tue Dec 06 04:20:37 EST 2005
· A Better Way ... by Rob Smith on Tue Dec 06 22:37:56 EST 2005
· NOT a better way... by Ivo Houbrechts on Wed Dec 07 10:19:15 EST 2005
· Good one by murukesh s on Wed Dec 14 00:33:16 EST 2005
Message #192428 Post reply Post reply Post reply Go to top Go to top Go to top
Concise code with Generics and varargs
Posted by: Geert Bevin on ??? 30, 2005 in response to Message #192425
I've been using this more and more to quickly initialize data structures in-place:
Map
put("Java", "Wicked");
put("C++", "Ok");
put("Ruby", "Interesting");
}};
没有评论:
发表评论