Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » [error] The nested type cannot hide an enclosing type([error] The nested type cannot hide an enclosing type)
[error] The nested type cannot hide an enclosing type [message #746510] Sun, 23 October 2011 13:46 Go to next message
Jonathan Camilleri is currently offline Jonathan Camilleri
Messages: 50
Registered: July 2009
Member
package javabeat.samples;

public class VolatileExample {

class ExampleThread extends Thread {
private volatile int testValue;
public ExampleThread(String str){
super(str);
}
public void run() {
for (int i = 0; i < 3; i++) {
try {
System.out.println(getName() + " : "+i);
if (getName().equals("Thread 1 "))
{
testValue = 10;
}
if (getName().equals("Thread 2 "))
{
System.out.println( "Test Value : " + testValue);
}
Thread.sleep(1000);
} catch (InterruptedException exception) {
exception.printStackTrace();
}
}
}
}
public class VolatileExample {
public static void main(String args[]) {
new ExampleThread("Thread 1 ").start();
new ExampleThread("Thread 2 ").start();
}
}

}

Sourced from http://www.javabeat.net/tips/169-volatile-keyword-in-java.html.

Error message: The nested type VolatileExample cannot hide an enclosing type
Re: [error] The nested type cannot hide an enclosing type [message #746606 is a reply to message #746510] Sun, 23 October 2011 15:16 Go to previous messageGo to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3189
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 2011.10.23 7:46, Jonathan Camilleri wrote:
> package javabeat.samples;
>
> public class VolatileExample {
>
> class ExampleThread extends Thread {
> [snip]

Is there a specific question in here somewhere?

Note that this forum is for handling issues mostly related to newcomers
to Eclipse. It is not a forum for answering questions about Java. For
that, you'd best head for javaranch.com, jguru.com or
stackoverflow.com--all great forums that answer very quickly and expertly.
Re: [error] The nested type cannot hide an enclosing type [message #748436 is a reply to message #746606] Mon, 24 October 2011 17:36 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric Rizzo
Messages: 2245
Registered: July 2009
Senior Member
On 10/23/11 11:16 AM, Russell Bateman wrote:
> On 2011.10.23 7:46, Jonathan Camilleri wrote:
>> package javabeat.samples;
>>
>> public class VolatileExample {
>>
>> class ExampleThread extends Thread {
>> [snip]
>
> Is there a specific question in here somewhere?
>
> Note that this forum is for handling issues mostly related to newcomers
> to Eclipse. It is not a forum for answering questions about Java. For
> that, you'd best head for javaranch.com, jguru.com or
> stackoverflow.com--all great forums that answer very quickly and expertly.

Russell is right.
I can tell you, however, that you simply have a transcription error -
the code you linked to is NOT the same as the code you posted.

Eric
Re: [error] The nested type cannot hide an enclosing type [message #894339 is a reply to message #748436] Sun, 08 July 2012 13:36 Go to previous message
Jonathan Camilleri is currently offline Jonathan Camilleri
Messages: 50
Registered: July 2009
Member
Oops, sorry about that, I should take coffee before reading Smile
Previous Topic:Help with Making Eclipse App a Mac App?
Next Topic:Creating a web service
Goto Forum:
  


Current Time: Wed Sep 17 03:44:58 GMT 2014

Powered by FUDForum. Page generated in 0.01767 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software