• Post Reply Bookmark Topic Watch Topic
  • New Topic

ON THREADS  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am geting compile time error on this below code whats wrong in this code ? HELP ME.

class Demo
{
public static void main(String[] ar)
{
Thread t=Thread.currentThread();
System.out.print(t);
System.out.println(t.getName());
}

}

I am geting this error
E:\java>javac Demo.java
Demo.java:7: cannot access Thread
bad class file: .\Thread.java
file does not contain class Thread
Please remove or make sure it appears in the correct subdirectory of the classpath.
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For starters, a class called Demo needs to be in a file called Demo.java, not gopal.java.
 
Sheriff
Posts: 21255
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you happen to have a class called Thread in your own project?
 
Sheriff
Posts: 57812
178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please don't write ALL IN CAPITALS.
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!