import java.util.*;

public class array1
	public static void main(String[]args)
      int[] value = new int[1000];

      Scanner keyboard = new Scanner(System.in);

      for (int i = 0; value[i]!= -999 && i < 999; i++)
         System.out.print("Enter number " +
                          (i + 1) + ": ");
         value[i] = keyboard.nextInt();
         	if(value[i] == -999)
         		System.out.print(" ");



public static boolean Scan1(int[] num1)
		int[] A = new int[1000];

			int i, j;
			for (i=0; num1[i] != -999 && i<-999; i++)
					for (j=i+1;num1[j] != -999 && j<-999; j++)
						if (A[i]==A[j])
						return true;

			}return false;

i want to calling the public static boolean Scan1(int[] num1) into main but i cannot do it.. can somebody tell me how?

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

7 Years
Discussion Span
Last Post by ainct
Featured Replies
  • You declared the method like this: [B]Scan1(int[] num1)[/B] And you are calling it like this: [B]Scan1()[/B] Something is missing Read More


You declared the method like this:
Scan1(int[] num1)
And you are calling it like this:
Something is missing


after i modified the code, im still cannot calling the boolean function.. help somebody!

import java.util.*;
public class array2
    public static void main (String[] args)
        boolean duplicate=true;
        int[] numtest;
        int size, num, num1,input;
        size = getArray(0);

        for (int i=0; i< size;i++)
            System.out.print(size +" ");

        num = getList(0);

        duplicate = getduplicate();

        System.out.println("You have enter duplicate number");

    public static int getArray(int size)
        Scanner input = new Scanner(System.in);
        size = 0;
        int[] list = new int[size];
        //System.out.println("Enter num :");
        for (int i=0; i< size; i++)
        return size;

    public static int getList(int num)
        Scanner input = new Scanner(System.in);
        int sum = 0, count=0;
        final int FLAG = -999; //end the scan num
        System.out.println("Enter the number end with " + FLAG);
        num = input.nextInt();
        while (num != FLAG)
            num=input.nextInt(); // end read the scan num           
        return num;

    public static void getduplicate(int num[])

    boolean found = true;
    boolean flag = false;
    int [] A = new int[1000];
    int i;
    int j = 0;
    for (i=0; i < num.length; i++) {
    if (A[i] == A[j])
    System.out.println("The number is duplicate"+found);
    else if (A[i] != A[j])
    System.out.println("The character is not a !flag"+flag);


Edited by Nick Evan: Fixed formatting


duplicate = getduplicate(); in the main method is without the argument. also in public static void getduplicate(int num[]) change void to int (if you want to return the integer number , as it expects).

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.