Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compile time error.

 
Madan Mohan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry frends...

i wrongly printed the code ....the code is as follows

import java.io.*;
public class SerializationDemo{
public static void main(String args[])
try{
MyClass object1 = new MyClass("Hello",-7,2.7e10);
System.out.println("Object : " +object1);
}

catch(Exception e){
System.out.println("Exception during serialization : " +e);
//System.exit(0);
}

}


class MyClass implements Serializable{

String s;
int i;
double d;

public MyClass(String s , int i, double d){

this.s=s;
this.i=i;
this.d=d;
}

public String toString(){

return "s=" + s + "; i=" + i + " ; d=" +d;
}

while compling this is giving me an error msg " ; expected"

can anyone catch where the error is occuring...
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Code tag always.


Write down these lines in a main() method.

 
Madan Mohan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey punit,

i wrongly printed the code...could you now tell me where the error is?

many thanks
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again you did not use code tag

I have solved your problem, only { brackets were missing just copy paste your code.

 
Madan Mohan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohh i amm so sorry for not using code. thanks for the help.

thanks a ton
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic