Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
What is the best way to implement a set interface in Java? Or more specifically, what is the best abstract data type to use when implementing a set interface? I need to create a set class in Java that implements a given set interface, but I'm wondering what the simplest way to do this is.
An interface example is java.util.Set, which is implemented by HashSet and TreeSet.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am new to Java Programming.
I want to understand the basic difference between the code below
this.customerPage.selectcustomerrecent(Customer);
this.customerPage = this.customerPage.selectcustomerrecent(Customer);
this.customerPage.selectcustomerrecent(Customer);
This piece of code means that customerPage is an instance variable and it has a method named selectcustomerrecent which takes argument of Class type Customer
this.customerPage = this.customerPage.selectcustomerrecent(Customer);
This is same as above and the only difference is that the response value of method selectcustomerrecent is reassigned to the instance variable customerPage.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have common methods written in different classes, making code duplicate and now to avoid this duplicacy, I am thinking of 2 approaches:
Make static methods in some util class and call them, or
Make a super class and write all these methods in super class and extend each class with this super class.
Definitely, with approach 2, I will loose the ability to extend my class further. So I am thinking to go with approach 1.
Can you please help me in identifying which approach is good and also in suggesting better approach, if you have any?
Creating Utility packages and/or class is a common solution to this problem. Apache Commons is a prime example. I would favour approach 1
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Given the following method of a class which doesn't have type T defined:
public <T> T get(java.lang.String name) { /* compiled code */ }
Would it be possible to invoke this, and how?
Yes. Just call it with an explicit type argument:
foo.<Integer>get("something")
I'm not terribly fond of how type arguments are expressed in Java, but they're perfectly doable. See the Java Generics Tutorial for another example.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Hello everyone I would like to know your preference regarding naming java packages. As in do you prefer com.example.controllers (since it contains a group of controllers) or com.example.controller ?
Also if you have an interface named Shape do you prefer to name it IShape or just Shape?
Based on standard package names, it should be singular :
java.util.function contains multiple functional interfaces.
java.util.stream contains multiple Stream interfaces and classes.
Etc...
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
If I have a variable defined in a method,can I get its Class Object using reflection
public void check(List<?> String> list){
Map<String,String> map // do something
}
Can i Obtain the Class Object to perform reflection for list and map variables,both are local variables
No, reflection does not expose local variables. Byte code analysis may help, but I don't know what you are trying to do.