might be main or another method // dont know yet

int[] num1 = new int[intA];
int[] num2 = new int[intB];


public static void cal(what do i put here)

blah blah

and

class Homework7v2
{
int a=0; // i need to use this int all the way through and
// it wont let me put it here>?
public static void main(String[] args)

Actually in a program (application) you will only have one main method.
All others are just classes (with no main method).

Same as in VB, you only have one 'Sub Main' routine.

i ment to another method as below

"public static void cal(what do i put here)"

any ideas?

If you are familure with VB, it is simular.

In your declared method, you declare the types of variables you wish to receive, like this:

// The below method (MyMethod) is passed two parameters, 
// one is a Integer, and another is a String
// It also RETURNS a character value
public char MyMethod(int myInt, String myString) {
    char someChar = 'A';  
    // someChar is my return value (which can be modified in the method)
    // You can then use myInt, and myString in your method
    //  ... Some other processing
    return someChar;
}  // End of MyMethod

Now to call this your would code:

// Somewhere in your program (can be in the main method, 
// or can be called in another method too)
returnChar = MyMethod( 1, "test string" );

// Noticed we passed an integer, and a string value.

Note - that 'returnChar' is declared somewhere in your program (mose times at the begining of the main, or it can be declare in the class or the method in which it is used. It just depends on how you wish to use 'returnChar' (look up scope.)

Also, you can have methods that do not return a value. In this case the above MyMethod would look like this:

// The below method (MyMethod) is passed two parameters, 
// one is a Integer, and another is a String
public [B]void[/B] MyMethod(int myInt, String myString) {
    char someChar = 'A';  // My return value (which can be modified in the method)
    // You can then use myInt, and myString in your method
    //  ... Some other processing
    // NO RETURN VALUE NEEDED
}  // End of MyMethod

Using the void return type you would not need to assign to a value. So you would just have:

// Somewhere in your program (can be in the main method, 
// or can be called in another method too)
MyMethod( 1, "test string" );

Lastly, you can have any number of parameters (or non at all,) just separate them with a coma. And don't forget to declare the type of parameter passed (since Java is a strongly typed language.)

Good Luck! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.