• Post Reply Bookmark Topic Watch Topic
  • New Topic

CAn I use Page^5 as a class name? I can't use it in eclipse but I am able to run it in Command line  RSS feed

 
Achari Chintaluri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Can some clarify !!!

I tried the follwoing simple program

public class Page^5{

public static void main(String[] args){
System.out.println("WELCOME");
}
}

I am able to run this program in Command. But I can't create a class Page^5 in eclipse.
Can someone explain me why?

I am using java 1.6

Thans in advance.





 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
Achari Chintaluri wrote:I am able to run this program in Command.

Really? I don't believe that, because this program doesn't even compile.

The character ^ is not a valid character that you can use in identifiers in Java (class names, method names, variable names etc.). Paragraph 3.8 of the Java Language Specification explains what characters you can and cannot use in identifiers.
 
Achari Chintaluri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesper,

Thanks for your reply. I am also surprised. But it is true.
Did you try this?

Attached the screen shots. But no other special charatcters is working except this.
Img1.JPG
[Thumbnail for Img1.JPG]
Img2.JPG
[Thumbnail for Img2.JPG]
Img3.JPG
[Thumbnail for Img3.JPG]
 
Achari Chintaluri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry img1 is wrong. i attached another one.....
Img4.JPG
[Thumbnail for Img4.JPG]
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this. The caret character (^) is a CMD.EXE escape character and it is ignored in this case. You're actually executing Page5.class in both cases. Hint: there is no Page^5.class in your listing - Page^5.java was never successfully compiled.

Look at the compiler output. That would give you more authoritative answer.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Next time, please copy and paste text instead of posting screenshots.

See Copy To the Clipboard From the Windows Command Prompt if you don't know how to copy and paste text from the Windows command prompt window.
 
Achari Chintaluri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martin,

Got it. Thank you very much for your help.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!