• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Compile error

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Suja Mudunuri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at The Java Tutorial.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic