public static int f (int []a, int []b,int []c)
        final int N=a.length;
        int j, k=0, g=0, t=0 ;
        for(int i=0;i<N;i++)
          for (j=0;j<N;j++)
           if (b[j]==a[i])
          if (j==N)
            if (g==0 || c[t]>k)


    return k;
4 Years
Discussion Span
Last Post by JamesCherrill

i need to test it.
i true to write main method and i cannt do this without errors
need help
tnx .

Edited by kbondarchuk: gammer mistake


Here's a little example:

public class A {
    public static void main(String a[]){
        print("Hello World.");

    public static void print(String str){

You'll have to include your main function, and your own function into a class. In Java everything has to be an Object/class, not like in C++ where we could had classes, and other small functions (a hybrid language).

So, try to create a class in which you'll put the static function public static void main(String a[]) which is the starting point of the program.


i wrote some main :

public static void main (String []args){
int[] arry= new a[];
 a[] = {1,1,2,3,3};
 b[]= {1,2,2,3,3};
 c[4]= {0,0,0,0,0};

the error : array dimension missing


The porblem is at line number 2
while initializing the array you must provide the array size.
hence modify the line 2 as below

 int[] arry=new int[5]; //5 is the array size and it can be any number   

also at line 7 -->

 system.out.println(k); // k is not defined anywhere

hence your code will not compile.

if you are trying to print the array then iterate the array and print each element of the array during iteration.

if you just print the array using its name then you will not see the elements inside the array.System just prints the array object.

Edited by subramanya.vl


as you are creating array in java, you have to also specify the size of it.
Also you have to define type of it like,int,string,double....

So modify it...and run it again..

int[] arry= new a[];

It's totally wrong.
The new operator from Java requires, when instantiating a new object, to have as it's right operands the constructor of the required object you want to instantiate, which, in your case, it's int ( and than size, if allocating an array).
But, you can also declare an array of ints in a C++ like thing:

int array[]={0, 1, 2, 3, 4, 5};

Presumably, that's what you were looking for.

public class A{
    public static void main(String arg[]){
        int array[]={1, 2, 3, 4, 5, 6};
        for (int i=0;i<5;i++)

    public static void print(String a){

A small point:
although the declaration syntax int arr[] is perfectly valid, most standards prefer the form int[] arr That's the form you will find throughout the Java API source code.
The reason is that arr is an array of ints, as implied by the second form. The first form seems to suggest that there is an array of arrs that is an int.

Edited by JamesCherrill

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.