Manfredo Kopfinger

Greenhorn
+ Follow
since May 15, 2006
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 Manfredo Kopfinger

You mean you need the <String> to tell the compiler that it's ok to assign this ArrayList object to the reference because I took care that it contains no wrong objects?
17 years ago
Hi!

I can't figure out the difference in protection from errors when I write:

ArrayList<String> list = new ArrayList<String>();
or
ArrayList<String> list = new ArrayList();

Can somebody give me a concrete code example where the first method detects and error that would not have been caught by the second method?

Because I can think of none.
17 years ago
Hi!

How can I start two different programs with one ant build-file?

when I write:

<target name="run">
<java classname="GUIApp" classpath="${cp.dir}" fork="true"/>
<java classname="ToolApp" classpath="${cp.dir}" fork ="true"/>
</target>

only the first program gets started and only when I close the first program, the second gets started.

How can I start them both, so that they run simultaneouslyP

[ July 21, 2006: Message edited by: Manfredo Kopfinger ]
[ July 21, 2006: Message edited by: Manfredo Kopfinger ]
17 years ago
Hi!

I constantly find it big pain searching through the java API documention for something.
I thought a program with a nice GUI, search function and some other gimmicks as a frontend to the documentation would be a cool thing.

Does anyone know a program like that?
Hi!

The book Head First Java (Second Edition, covering Java 5.0) says that when I want to add a button to a JFrame, I have to write:


But I found out that it also works when I only write


What are the differences between the two approaches? Is it favorable to write JFrame.getContentPane().add(button); ?
17 years ago
Hi!

Here something I just noticed. When you make an inner class inherit from another class that has static fields and methods, the inner class also has these static members, even though it cannot declare static members by itself.

Look at this piece of code:



With this method, the derived class has static and non-static members just like a top-level class, plus it can access the members of the enclosing class.

I wonder why the java designers didn't make inner classes just work like that, it would be much more logically to me.

Are there any technical reasons that that the java designer didn't implement it to work like that? Or is it bad practise?
[ May 31, 2006: Message edited by: Manfredo Kopfinger ]
17 years ago
Hi!

What I don't really get is the way that inner classes and nested classes work, the whole thing seems a bit inconsistent to me.

For example take the following code:



In this example you can access the variable i inside a static method in the outer class without creating an object of the outer class, even though the Inner class is a non-static member of the outer class. Isn't that strange?

Furthermore,you can also access i in a non-static method of the outer class like this:



but funnily enough you can't do the same from Main:



Can somebody tell me why this examples behave the way they do?
Probably somebody can provide some technical background regarding the Inner Classes that make it clear why they behave like they do.
17 years ago