I have a class Car with numDoors, numPassengers, maxSpeed as integers.
and then a few functions returning void, one of them is: void reverse(int units) it returns nothing but takes units, when I call it in main I get an error, I think I`m not calling it properly.

Every method call needs to match the way it was set up. Since you have a method called "void reverse(int units)", the method call is going to need to be set up so it enters a number of units and returns nothing. If you say System.out.println(myCar.reverse()), you are going to have two problems.

First, you can't call reverse() by itself because it needs a number inputted as specified by "int units". I don't know what your reverse method is supposed to do since you didn't paste that part of the code, but if it needs an inputted number of units to work correctly calling reverse() won't work because you aren't giving it a number of units to work with. If you call reverse(5) that problem will be solved, and when the program uses the reverse function the int units will be set to 5.

The second problem that you have with your code is that your method has a return type of "void" -- as you said, it returns nothing. If your method is supposed to return something, then it can't be of type void. If your method is supposed to return nothing, then you can't print the value it returns, because it isn't returning anything.

Another possibility is to change the method signature -- if you want it to work with System.out.println(myCar.reverse()), then your method header would look something like "int reverse()" instead of "void reverse(int units)". This way there are no units that need to be inputted and a value to be printed is returned. I'm not sure what your objective is, but you either have to change the way your method works or the way it is called.

If reverse() is a void, then it's not what you want to pass into a println call. Further, if the signature of reverse is void reverse(int units) , then you need to pass in an integer in order to be able to use it.

I don't know what the intent of your code is, but if you want to print the output, you either need to place the print functionality in the reverse function, or (preferrably) return something from reverse and print it from your main method.

As far as calling something with a return type, let's say you have a function with a signature like the following: public static int ReturnSomething(int input) Then you would call it in such a manner as this int output = ReturnSomething(5); // or a variable Edit: How did I randomly pick the same number as someone posting at just about the exact same time? This is a glitch in the matrix, isn't it?

Yes, that will work. However, since the variable maxSpeed is in your car, you could also just have myCar.reverse() not take units, and in the actual method just directly access the maxSpeed variable. Here is an example of what your car class probably looks like:

Point being, you don't need to get a variable from myCar only to stuff it right back in again -- just leave it there to begin with. I also recommend you look up encapsulation online, because your code is vulnerable to errors without it if others use your class. It's a good practice to encapsulate your code (the getter-setter functions someone mentioned earlier)