For the car program given in the notes.I compiled the program using "javac Car.java" command.The program is getting compiled but when i am giving the command"java Car" to run the program, i am getting the error message"exception in thread"main" java.lang.No such Method error:main".
But when i executed the same program on eclipse"platform for executing java pgm" it is getting executed.Help me with the reason behind it.
Hi Everyone please help me out
class floatnum
{
public static void main (String args[])
{
float a=1.2;
System.out.println("The floating point number is :" " " a);
}
}
The above programme shows the following error at compile time
float a=1.2
possible loss of precision
Found: double
Required: float
Where and how can I use float data type
I installed JDK.While compiling a program,I was getting error message 'javac' is not recognised as an internal or external command,operable program or batch file.In notes it is mentioned to set path using command.But after setting the also i m getting the same error as mentioned above.
Help me..
well in the above program there is a compilation error like--
"SingleThread.java uses or overrides a deprecated API.
Recompile with -XLint: deprecation for details."
Is it possible to create many public classes in one program?
Kindly have a look at the program below:-
public class Me
{
int age;
String name;
public void age(int value)
{
age=value;
}
void name(String string)
{
name=string;
}
public void printname()
{
System.out.println("My name is " name );
}
public void printage()
{
System.out.println("My age is " age " years");
}
}
public class Myself
{
public static void main(String args[])
{
Me m=new Me();
m.name("Ajanta");
m.printname();
}
}
public class Myself1
{
public static void main(String args[])
{
Me m1=new Me();
m1.age(22);
m1.printage();
}
}
error message thrown on compiling the program as-
javac Myself.java
C:\Program Files\Java\jdk1.6.0\bin>javac Myself.java
Myself.java:1: class Me is public, should be declared in a file named Me.java
public class Me
^
Myself.java:38: class Myself1 is public, should be declared in a file named Myse
lf1.java
public class Myself1
^
2 errors
C:\Program Files\Java\jdk1.6.0\bin>
While compiling as:- javac Myself1.java doesnt throw any error.
Kindly have a look at the following at the prog which runs successfully:-
class Me
{
int age;
String name;
public void age(int value)
{
age=value;
}
void name(String string)
{
name=string;
}
public void printname()
{
System.out.println("My name is " name );
}
public void printage()
{
System.out.println("My age is " age " years");
}
}
class Myself
{
public static void main(String args[])
{
Me m=new Me();
m.name("Ajanta");
m.printname();
}
}
class Myself1
{
public static void main(String args[])
{
Me m1=new Me();
m1.age(22);
m1.printage();
}
}
PLease explain the reason, why is the program behaving like that?????