Eclipse Java包名称顺序搜索

时间:2016-02-16 12:26:57

标签: java eclipse package sequential

顺序搜索问题,我尝试调试了一下,但问题出在包名...我应该更改什么?

package pcsettingfirstpj;

public class Sequential {

    private static int sequential(int[] data, int target){
        int i;
        for (i = 0; i < data.length; i++)
            if (data[i] == target)  return i;
        return -1;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int[] data = {89, 34, 78, 45, 12, 99, 23};
        int i;
        java.util.Scanner sc = new java.util.Scanner(System.in);
        System.out.println("Please input value: ");
        int target = sc.nextInt();
        System.out.print("Original array: ");
        for (i = 0; i < data.length; i++);
            System.out.print("[" + data[i] + "]");
        System.out.print("\n");
        int pos = sequential(data, target);
        if ( pos != -1){
            System.out.print("Found: " + target);
            System.out.println("(" + pos + ")");
        }
        else System.out.println("Not found: " + target);
        sc.close();
    }

}

如何不使用包裹?这是必须的吗?

感谢您的回复。我今天发现它很好吗?!

0 个答案:

没有答案