import java.io.*;
class method
{
public static void main(String args[])
{
System.out.println("hey ho");
void clear()
{
System.out.println("Finally its working ");
}
}
}
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
import java.io.*;
class method
{
public static void main(String args[])
{
System.out.println("hey ho");
void clear()
{
System.out.println("Finally its working ");
}
}
}
My question: Are there any lines of this code which seem unnecessary?
Welcome to the forum! Please read this topic to learn how to post code correctly and other info useful to newcomers.
when i run dis code method part shows errors
the unnecessary line(println before method) u r referring is just to check if dere is any other problem ...... do u know wen does this happens ...
Please copy the full text of the error messages and paste it here.shows errors
If you don't understand my answer, don't ignore it, ask a question.
The 'main' is just a method, just like your 'clear' method. You need a main method so java knows where to start executing your application.
So what you are trying to do now is placing a method (clear) in another method (main) which isn't possible.
What you could do is call the 'clear' method from the main method, like this:
You don't have to import java.io.* btw
yaa ryt thnx for the important tip .... but a small correction non static method can't be called with static context so either call them with a object or use it as a static method .....
anyways than a ton was stuck on this for quite a long tym
class method
{
public static void main(String fdff[])
{
System.out.println("hey ho");
clear();
}
public static void clear() //static method
{
System.out.println("Finally its working ");
}
}