Skip to content

Tag: java

Java: Rotating Images

I need to be able to rotate images individually(in java). The only thing I have found so far is g2d.drawImage(image, affinetransform, ImageObserver ). Unfortunately, I need to draw the image at a specific point, and there is no method with an argument that 1.rotates the image separately and 2. allows me to se…

declare multiple arraylists

is it possible to declare 2 array lists in the same line? e.g: Is it then possible to do something like: Obviously, I get a compile error when I do the above, and was wondering how could one declare 2 lists in the same line. Answer If you want that, you should do:

Retrieve test name on TestNG

Can I retrieve currently running test name like in JUnit (using getName() or rules)? P.S. I don’t want use some self-written tool based on stack traces. Answer According the to TestNG documentation at: http://testng.org/doc/documentation-main.html you can implement listeners that might be able to help y…

Android Resources Class Memory Usage

I’m making modifications to the Android 4.0 launcher and I have been running into many OutOfMemoryErrors. Since the 4.0.3 update it got much worse (or started, it seems before it was fine, but I never got to test properly) and I have tried many many things to fix it. The error is also in the stock launc…

Java Delay/Wait

How do I delay a while loop to 1 second intervals without slowing down the entire code / computer it’s running on to the one second delay (just the one little loop). Answer

How does Java deal with multiple conditions inside a single IF statement

Lets say I have this: Now. Is Java smart enough to skip checking bool2 and bool3 if bool1 was evaluated to false? Does java even check them from left to right? I’m asking this because i was “sorting” the conditions inside my if statements by the time it takes to do them (starting with the ch…

Java visitor pattern instead of instanceof switch

In this question it is said I can use visitor pattern instead of a bunch of instanceofs. Jmg said “If you are not free to change A, B, and C, you could apply the visitor pattern to achieve the same.” As far as I understand I still have to make A, B and C support visitor (have an accept() method,