Questions tagged [java-5]

Java SE version 5 was released in September 2004 and is no longer supported by Sun as of November 2009. Use only if your question is specifically related to features of this version.

Java version 5 (or 1.5).

Use only if your question is specifically related to features of this version. Just because you are using this version, doesn't mean you need this tag. Use in addition to or instead of this tag.

See for more information.

350 questions
1031
votes
33 answers

How do I join two lists in Java?

Conditions: do not modify the original lists; JDK only, no external libraries. Bonus points for a one-liner or a JDK 1.3 version. Is there a simpler way than: List newList = new…
Robert Atkins
  • 23,528
  • 15
  • 68
  • 97
183
votes
21 answers

Why do people still use primitive types in Java?

Since Java 5, we've had boxing/unboxing of primitive types so that int is wrapped to be java.lang.Integer, and so and and so forth. I see a lot of new Java projects lately (that definitely require a JRE of at least version 5, if not 6) that are…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
155
votes
8 answers

How to set a JVM TimeZone Properly

I am trying to run a Java program, but it is taking a default GMT timezone instead of an OS defined timezone. My JDK version is 1.5 and the OS is Windows Server Enterprise (2007) Windows has a Central timezone specified, but when I run the following…
Kushal Paudyal
  • 3,571
  • 4
  • 22
  • 30
77
votes
13 answers

Java reading a file into an ArrayList?

How do you read the contents of a file into an ArrayList in Java? Here are the file contents: cat house dog . . .
user618712
  • 1,463
  • 7
  • 17
  • 19
73
votes
6 answers

Java Generics: Generic type defined as return type only

I'm looking at some GXT code for GWT and I ran across this use of Generics that I can't find another example of in the Java tutorials. The class name is com.extjs.gxt.ui.client.data.BaseModelData if you want to look at all of the code. Here are the…
Jason Tholstrup
  • 2,036
  • 3
  • 21
  • 25
73
votes
4 answers

How to redirect verbose garbage collection output to a file?

How do I redirect verbose garbage collection output to a file? Sun’s website shows an example for Unix but it doesn't work for Windows.
djangofan
  • 28,471
  • 61
  • 196
  • 289
36
votes
2 answers

What is the easiest way to iterate over all the key/value pairs of a java.util.Map in Java 5 and higher?

What is the easiest way to iterate over all the key/value pairs of a java.util.Map in Java 5 and higher?
flybywire
  • 261,858
  • 191
  • 397
  • 503
36
votes
11 answers

Reasons and advantages for upgrading to Java 6 for a non-technical decider (at the client)

I'd like to upgrade from Java 5 to Java 6. We all know about the technical advantages and benefits, but: I have the problem that a major client refuses to upgrade from java 5 to java 6 because of "the risks" and "no/too few benefits for us" (banking…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
33
votes
1 answer

What are the 37 Java API packages possibly encumbered by the May 2014 Oracle v Google decision?

What are the 37 Java API packages possibly encumbered by the May 2014 Oracle v Google decision? What are the 3 packages that the Appellate Court decided were essential to the language? How can I avoid using the encumbered APIs in my Java code? If…
Karl the Pagan
  • 1,944
  • 17
  • 17
32
votes
4 answers

Mockito isA(Class clazz) How to resolve type safety?

in my test I have the following line: when(client.runTask(anyString(), anyString(), isA(Iterable.class)).thenReturn(...) isA(Iterable.class) produces warning that it needs unchecked conversion to conform to Iterable . What is syntax for…
Mike
  • 591
  • 1
  • 4
  • 7
27
votes
7 answers

How to disable TestNG test based on a condition

Is there currently a way to disable TestNG test based on a condition I know you can currently disable test as so in TestNG: @Test(enabled=false, group={"blah"}) public void testCurrency(){ ... } I will like to disable the same test based on a…
Afamee
  • 5,160
  • 9
  • 38
  • 43
25
votes
5 answers

What is the use of in public static T addAndReturn(T element, Collection collection){

I get confused when I come across a generic method of this sort. public static T addAndReturn(T element, Collection collection){ collection.add(element); return element; } I cannot understand why is required in this method. Also,…
Jegan Kunniya
  • 986
  • 3
  • 17
  • 27
23
votes
4 answers

Why wasn't java.io.Serializable deprecated in Java 5?

In pre Java 5, there were no annotations. As a result you could not add metadata to a class. To mark a class as serializable, you had to implement the Serializable interface (which is just that, a marker) and use further transient keywords to mark a…
ElenaT
  • 2,600
  • 4
  • 24
  • 41
23
votes
4 answers

JAXB unmarshalling ignoring namespace turns element attributes into null

I'm trying to use JAXB to unmarshal an xml file into objects but have come across a few difficulties. The actual project has a few thousand lines in the xml file so i've reproduced the error on a smaller scale as follows: The XML file:
user227614
  • 233
  • 1
  • 2
  • 4
20
votes
5 answers

java.lang.InternalError: name is too long to represent

I get this error: java.lang.InternalError: name is too long to represent at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at…
Paolo
  • 2,461
  • 5
  • 31
  • 45
1
2 3
23 24