Skip to content

Tag: java

How to copy a java.util.List into another java.util.List

I have a List<SomeBean> that is populated from a Web Service. I want to copy/clone the contents of that list into an empty list of the same type. A Google search for copying a list suggested me to use Collections.copy() method. In all the examples I saw, the destination list was supposed to contain the …

What is inverse function to XOR?

There is XOR function in Java – a^b For exemple: 5^3 = 6 Can you tell me inverse function? If I have 6 and 3 can i get range of numbers which include number 5? Answer The inverse is XOR! If you have: You can get a or b back if you have the other value available: For example if

ResultSet getFetchSize() doesn’t seem to work?

I’m having trouble with the getFetchSize() function. I simply need to know if the SQL query has returned zero rows. I’ve tried this simple statement: where rs is of the ResultSet type. The above code doesn’t seem to work. It always prints the message whether rs is empty or not. I checked the…

JavaFX 2 set/get cursor position

How can I set/get the cursor’s position in JavaFX 2? I tired googling the answer but found nothing useful. All I can do is setting the cursor’s style. Answer You can use robot for that purpose: AWT robot: http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/Robot.html or glass robot: com.sun.glas…

Check if arraylist contains only nulls

I think there has to be a better way of doing this.. I have a call to a function that returns an ArrayList. If that ArrayList only returns 10 null items (the default), is there a way of checking this without iterating through all 10 items to see if they are null? Answer Generally, no; there is no other way