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

need help  RSS feed

 
vikash dwivedi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Add
{
public show()
{}
}
hi all,


public class Nov
{
Add a;
a.show();
}

this code is correct or not? because reference dont have memory existence.

with the help of this code i want to know that can we call the method 'show()' by 'a' reference of class 'Add'.


thanks in advance
bye
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are more than a few syntax errors and general mistakes in the code you posted. I suggest you find a good beginner's book on Java, like Head First Java and start reading. Sun's tutorials are also useful: http://java.sun.com/docs/books/tutorial/index.html
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first step in testing if a program is "correct" is to compile it. What happens when you compile this code?

Layne
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vikash dwivedi:
class Add
{
public show()
{}
}
hi all,

There's a few problems right here, namely that 'hi all,' appears outside the context of a method and if it is text it should be surrounded by quotes as well. In addition, the method show() must be define a return type or void. As it is declared, show() has no return type.

Originally posted by vikash dwivedi:
this code is correct or not?

No, it needs a far bit of basic syntax work.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!