This question already has an answer here:
Closed 12 years ago.
Possible Duplicate:
Explain the generics used in the Enum declaration
Guys I can't get my head around this:
Enum<T extends Enum<T>>;
How on earth shall I understand this declaration?
There is an explanation here.
Related
This question already has answers here:
What is the use of an empty abstract class?
(3 answers)
Closed 5 years ago.
Yesterday, I had an interviewing with a company.
They ask me "Why do we need an empty class in Java?"
I never use an empty class so I have no idea about the purpose of this.
Anyone help?
Thank you so much.
No, we don't need an empty class in Java. We can create one but there is literally no benefit of having that empty class.
This question already has answers here:
Create a mutable java.lang.String
(6 answers)
Closed 5 years ago.
I want to make String class mutable, simplest way to do this is make inner char array is public. How can i achive it?
I'm pretty new to this so sorry if this is wrong.
Wouldn't it be possible to inherit from the String class then override the required method?
Adam
This question already has answers here:
Casting variables in Java
(5 answers)
Downcasting in Java
(12 answers)
Closed 6 years ago.
As the title,
Assume that there's a KiahApplication class that extends Application,
I've seen the code below:
KiahApplication Kapp=(KiahApplication)getApplication();
But isn't it incorrect to cast a superclass to its subclass?
Thank you so much for helping!
No, it's not illegal and sometimes is necessary. The important thing is to be sure that the object is an instance of the subclass. You can do this by testing it in code or by catching the potential ClassCastException. In the example you give, if you are absolutely sure that the Application object is of the right type then you could leave as is.
This question already has answers here:
What does this Java generics paradigm do and what is it called?
(3 answers)
Generic Interface takes self as Parameter. Recursive Generic? [duplicate]
(1 answer)
Closed 9 years ago.
In which situations would we use the following technique?
class A<T>
class B extends A<B> // the B appears twice
What are the benefits of such an approach?
For example, I have seen such a definition:
class HttpBase<T>
Then
class HttpRequest extends HttpBase<HttpRequest>
Also
class HttpResponse extends HttpBase<HttpResponse>
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What is the difference between Class.this and this in Java
I know what this means in Java, but sometimes I see something like SomeClass.this, what does it mean? does it refer to a static class filed? Could you please explain with an example?
Thanks.
It is a way code in a method of your inner class can refer to the encompassing outer class instance.