Forums Register Login

Compile error

+Pie Number of slices to send: Send
This is my method and in this method I am doing different mathematical operations. I am calling this method by passing an int.
Compiler gives me the following errors. I don't understand why. Can somebody help me?

int x = 2;
Vnumbers(x);

public void Vnumbers(int a){
int b = a;
System.out.println("Value of b is : " + b);
}


C:\Sujatha\MyProjects\java\Hellow.java:39: invalid method declaration; return type required
Vnumbers(x);
^
C:\Sujatha\MyProjects\java\Hellow.java:39: <identifier> expected
Vnumbers(x);
^
C:\Sujatha\MyProjects\java\Hellow.java:39: ')' expected
Vnumbers(x);
^
3 errors


int x = 2;
Vnumbers(x);

public void Vnumbers(int a){
int b = a;
System.out.println("Value of b is : " + b);
}
+Pie Number of slices to send: Send
Hi,

It looks like you are calling the method in the top level of the class, rather than in the body of another method?



Could you post your entire class source please?
+Pie Number of slices to send: Send
Yes, that is what I have done. I corrected it and it is working fine.
Thank You.
I am looking for some samples to review all my basics. If you have any samples can you please give me?

Regards,
+Pie Number of slices to send: Send
Have a look at The Java Tutorial.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 620 times.
Similar Threads
Cannot able to get the Output
ClassPath problem
Exception Handling
If condition
how the program works?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 22:22:18.