Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

namespaces  RSS feed

 
smitha sudeesh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi frnds,

I have a very simple code that i am unable to run.Can some one help me out

public class Name{
Name() {
System.out.println( "I am a constructor") ;
}
void Name()
{
System.out.println("I am a method");
}
public static void main(String[] args){
new Name().Name();
}
)

this is the error i get when i try to compile it.

C:\Java>javac Name.java
Name.java:12: illegal start of type ) Name.java:13: <identifier> expected ^
2 errors


Can we write statements such as these - new Name().Name();

and if so why doesn't this prgm compile.
thanks in advance
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's goofy but you can do it. Look at the bottom line. You have ) instead of }
 
smitha sudeesh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!