This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Parameters and Function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parameters and Function" Watch "Parameters and Function" New topic
Author

Parameters and Function

paulo cs
Ranch Hand

Joined: Dec 30, 2008
Posts: 34
These parameters are giving error. Why? The parameters: a,b and c.


This is message error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method calc(int) in the type Bascara is not applicable for the arguments (int, int, int)

at Bascara.main(Bascara.java:15)


Paulo Correa, Desenvolvimento de Software, (55 19)8126-8418
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16


Try to search how to declare method arguments in Java.


[My Blog]
All roads lead to JavaRanch
Guilherme Borges Lima
Greenhorn

Joined: Jun 04, 2008
Posts: 11
You must define the types of all arguments of your methods

a = int
b = ?
c = ?

try this:
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Guilherme, welcome to the ranch
You should have a look at this FAQ to help other ranchers more efficiently.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19726
    
  20

Paulo, may I suggest you do some reading first? You said in another thread you recently started Java after using Delphi before that, so you probably understand the basics but not the syntax and Java specifics.

The Java Tutorial and/or books like Head First Java are real great to start with.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
We don't usually give out straight answers to things people can look up for themselves, but I believe here it is right to give you the answer. Guilherme Borges Lima has shown you the correct version.

As you obviously already know, one has to give a type for each variable, field, parameter, etc. For parameters, you cannot give one type to two parameters.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19726
    
  20

Paulo's syntax comes from Delphi / Pascal, where you only specify the type when it changes. So the following are all Delphi / Java pairs:
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
That syntax looks like Eiffel syntax, which I am sure is copied almost unchanged from Pascal syntax.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parameters and Function