In java Programming this basic use [closed] - java

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.

Related

Set interfaces in Java [closed]

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.

Would it be possible to call this generic method? [closed]

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.

Can I obtain a Class Object for a local variable of a method using Reflection [closed]

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.

Java Exception (if a method returns false) [closed]

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 9 years ago.
Improve this question
Is there a way to catch an exception if a certain "validate" method returns a false?
I am validating certain values given to the object and I want to throw an exception and print out an error message (but continue the program) when the valdation (which is called via the constructor) fails so that the object will not be created.
if (!validate())
throw new Exception();

What is the term used to describe assigning values to an object without first instantiating it? [closed]

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
E.g.
Car myCar = Car.Ford
instead of
Car myCar = new Car();
myCar = Car.Ford
I don't think there is a separate term. You appear to understand the terms assignment, and instantiation. You're just looking for non-instantation assignment at time of declaration?

Categories