Basic java Error program
1:-
class Demo{
System.out.println("Error find"); yha pe Sop nahi laga sakte hai error dega..
public static void main(String args[])
{
}
}
Output
C:\java>javac Testing.java
Testing.java:2: error: <identifier> expected
System.out.println("Error find");
2:-
lass Demo{
}
class mytest{
public static void main(String args[])
{
System.out.println("error find");
}
}
Output
C:\java>javac Testing.java
C:\java>java Demo (Hamesha jis class me main method rahata usi ko call karte hai )
Error: Main method not found in class Demo, please define the main method
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
1.
class aman{
System.out.println("sonu");
}
class aman{
System.out.println("sonu");
}
System.out.println("sonu");
}
2:-
class aman{
public int a=10;
public int b=20,c;
}
class xyz {
public static void main(String args[]){
c= a+b;
System.out.println("sum of number is="+c);
}
}
3:- METHOD
class aman{
void show() // Ager mai show method ko static ban dege ko error nahi ayga
{
System.out.println("This is java language");
}
}
class xyz {
public static void main(String args[]){
aman obj= new aman();
aman.show();// this is function
}
}
OUTPUT
es progaram error aya hai kuki ham show method ko static nahi banya hai or use functio me call kar diya hai ..
C:\java>javac Testing.java
C:\java>java xyz
C:\java>javac Testing.java
Testing.java:15: error: non-static method show() cannot be referenced from a sta
tic context
aman.show();
^
1 error
4:-
class Demo
{
public static void main(String arg[])
{
}// yha hai }
C:\java>javac Testing.java
Testing.java:13: error: <identifier> expected
Public static void main(String arg[]){
^
Testing.java:20: error: reached end of file while parsing
}
^
2 errors
C:\java>
is program me erroe aya kui main ke bricket close nahi kiya hai
5:-
class
{
Public static void main(String arg[]) //yha pe
{
}
}
OutputC:\java>javac Testing.java
Testing.java:13: error: <identifier> expected
Public static void main(String arg[]){
^
1 error
C:\java>
is progarm me error aya hai ki isme public ka p capital me lik diya hai.
6:-
class Demo
{
public static void main(String arg[])
{
System.out.prinln("Sonu");
}
}
C:\java>javac Testing.java
Testing.java:6: error: cannot find symbol
System.out.prinln("Sonu");
^
symbol: method prinln(String)
location: variable out of type PrintStream
1 error
C:\java>c
Comments
Post a Comment