search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

Recent questions tagged core-java

0 votes
1 answer 20 views
If I have two variables: Object obj; String methodName = "getName"; Without knowing the class of obj, how can I call the method identified by methodName on it? The method being called has no parameters, and a String return value. It's a getter for a Java bean.
asked john Guru 27.1k points 31 50 97
0 votes
2 answers 13 views
I have a try/catch block with returns inside it. Will the finally block be called? I have a try/catch block with returns inside it. Will the finally block be called? For example: try { something(); return success; } catch (Exception e) { return failure; } finally { System.out.println("i don't know if this will get printed out."); }
asked john Guru 27.1k points 31 50 97
0 votes
1 answer 19 views
In Swing, the password field has a getPassword() (returns char[]) method instead of the usual getText() (returns String) method. Similarly, I have come across a suggestion not to use Strings to handle passwords. Why does String pose a threat to security when it comes to passwords? It feels inconvenient to use char[].
asked john Guru 27.1k points 31 50 97
0 votes
2 answers 38 views
0 votes
1 answer 13 views
asked john Guru 27.1k points 31 50 97
0 votes
1 answer 24 views
a can only be final here. Why? How can I reassign a in onClick() method without keeping it as private member? private void f(Button b, final int a){ b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { int b = a*5; } }); } How can I ... ClickHandler() { @Override public void onClick(ClickEvent event) { int b = a*5; return b; // but return type is void } }); }
asked john Guru 27.1k points 31 50 97
1 vote
1 answer 20 views
asked keem Expert 13.2k points 27 40 59
1 vote
1 answer 25 views
what is the use of the for each loop over the for loop?
asked keem Expert 13.2k points 27 40 59
1 vote
1 answer 34 views
What's the simplest way of printing an array of primitives or of objects in Java? Here are some example inputs and outputs: int[] intArray = new int[] {1, 2, 3, 4, 5}; //output: [1, 2, 3, 4, 5] String[] strArray = new String[] {"John", "Mary", "Bob"}; //output: [John, Mary, Bob]
asked keem Expert 13.2k points 27 40 59
0 votes
1 answer 24 views
I work with Java all day long. The most used idiom (code snippet) I'm programming in Java, is to test if an object != null before I use it. This is to avoid a NullPointerException. I find the code very ugly and it becomes unreadable. Is there a good alternative to avoid this code snippet?
asked john Guru 27.1k points 31 50 97
0 votes
1 answer 21 views
I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson()
asked john Guru 27.1k points 31 50 97
0 votes
2 answers 22 views
Is there any method to generate MD5 hash of a string in Java?
asked john Guru 27.1k points 31 50 97
0 votes
2 answers 1.3K views
0 votes
1 answer 28 views
asked keem Expert 13.2k points 27 40 59
0 votes
2 answers 70 views
I am trying to create a button that has a custom shape (hexagon), but otherwise acts like a normal JButton would (that is, works with an ActionListener).
asked sara Guru 24.6k points 29 52 81
0 votes
1 answer 25 views
asked john Guru 27.1k points 31 50 97
0 votes
2 answers 31 views
When should LinkedList be used over ArrayList and vice-versa?
asked john Guru 27.1k points 31 50 97
0 votes
2 answers 20 views
What is the main difference between a inner class and a static nested class in Java? Does design /implementation play a role in choosing any of these?
asked john Guru 27.1k points 31 50 97
...