rhett howard

Greenhorn
+ Follow
since Nov 24, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by rhett howard

Hey guys,
I just completed it.I got an 80%............I have to say thank you to all of you for posting great questions and also answering them here........

Gracias.....

14 years ago
Hey Ankit,
Do you still have this blog working?? I read the static inner classes section and i found it pretty useful.But, I can't access the other parts of the blog.

Is there some other place i can read them?

Thanks a lot.



Okie, I understand it something like this......

Since C can't be subclassed anymore, compiler figures out there can't be any subclass which can implement Runnable and so it won't allow any casting to runnable???.......

Looks like thats the answer!!.....Let me know if it isn't......

Now i wonder why i even posted this question???......

Even //1 doesn't compille when i say


Runnable r1 = (runnable) c;


Is it because class c is final???...


If that is so, I am even more confused???
Hey guys,
I have a question about casting in this code from one of the devaka K examlabs........

Kinda confused with the whole typecasting thing.......


class B extends A{}
final class C extends B{}

class A{
public static void main(String args[])
{
A a = new B();
B b = new B();
C c = new C();
C[] ca = null;
a = b;
b = c;
A a1 = (B) c;
Runnable r1 = (Runnable) a; //1
Runnable [] ra1 = null;
A r2 = (A) r1;
A[] aa1 = (A[])r1; //17
A[] aa2 = (A[])ra1; //18
ra1 = (Runnable[]) ca; //19
}
}



Why is line 19 giving compile time error when line 18 isn't?

Thanks in advance!!!
Oh, okie......I didn't know constructors of enum are implicitly private.I thought it had default modifier when we dont give any modifier.....But looks like its allowed only a private modifier.

Thanks......

Thanks Bob and Pete.
But why isn't public allowed for the constructor?
Hey guys,
I was wondering about the use of private constructor inside an enum which is outside the class........I am still able to initialize the object from another class, rite??

And why is public not allowed there???


package javaapplication3;

enum coffeeSize { Big(1), Small(4), Verysmall(5);
public int points;
private coffeeSize(int points)
{
System.out.println("hello");
this.points = points;
}
int getval()
{
return points;
}
}


public class Main
{


public static void main(String [] args)
{
coffeeSize size = coffeeSize.Small;
// coffeeSize cs [] = size.values();
// for(coffeeSize cl : cs)
System.out.println(size);

}
}


Output:

run:
hello
hello
hello
Small
BUILD SUCCESSFUL (total time: 0 seconds)



Thanks .


I thought he was confused too....

thanks......
Now I am wondering watz wrong with anonymous classes inside a static method?..

Ruben, you just used one inside the static main method , rite?.......

It didn't baffle me at all!!!


Thanks.......
Yeah , I was reading this article
http://mindprod.com/jgloss/anonymousclasses.html

and it says :
If you want to baffle those maintaining your code, wags have discovered javac.exe will permit anonymous classes inside static init code and static methods, even though the language spec says than anonymous classes are never static. These anonymous classes, of course, have no access to the instance fields of the object. I don’t recommend doing this. The feature could be pulled at any time.


I don't know when this article is written, but is this feature already pulled? ...........
Thanks guys!!
That makes sense!! I wasn't really thinkin' about polymorphism inside a class.


Btw, If an inner class is abstract, does it make the enclosing class abstract too like with the instance methods?