Java 哪一个是线性和二进制搜索的效率

Java 哪一个是线性和二进制搜索的效率,java,Java,这是我自己试过的代码。 我在返回(b)中有一个错误,表示“b”未初始化…请帮助。替换 public enum Color { Red, Orange, Yellow, Green, Cyan, Blue, Purple; private boolean isRGB(Color color) { boolean b; switch(color){ case Red: System.out.println("M

这是我自己试过的代码。 我在返回(b)中有一个错误,表示“b”未初始化…请帮助。

替换

public enum Color {
    Red, Orange, Yellow, Green, Cyan, Blue, Purple;


    private boolean isRGB(Color color)
    {


    boolean b;

    switch(color){
        case Red:
            System.out.println("Monday is a work day!!");
            break;
        case Orange:
            System.out.println("Tusday is a work day!!");
        case Yellow:
            System.out.println("Wednesday is a work day!!");
        case Green:
            System.out.println("Thursday is a work day!!");
        case Cyan:
            System.out.println("Friday is a work day!!");   
        default:   b = false;

        System.out.println("Sorry this is not a working day!!\nn");
        System.out.println("It's weekend!!!");
    }
    return(b);
}


public enum Color{//..
-老师添加了点,但没有要求添加任何内容

boolean b = true;

有人能帮我找出我做错了什么吗!!!这是练习题,如果需要的话,“……写一个程序来检查它是否是三种原始颜色之一(红-绿-蓝,RGB。周一、周二、周五是工作日。这与问题的标题有什么关系?提示:如果
color
Red
,您认为
b
的值是什么?@TobiasWürth:对于局部变量,同样不正确。默认情况下只有字段被初始化。这不是对如果你想编辑你的问题,点击“编辑”链接。
boolean b = true;
public enum Color {
    Red, Orange, Yellow, Green, Cyan, Blue, Purple;    
}

private boolean isRGB(Color color) {

    boolean b = false;

    switch (color) {// i supposed to fill the blank switch(        )
        //And also i supposed write  all the statements for switch, thats all was required me to do!!
        case Red:
            System.out.println("Monday is a work day!!");
            break;
        case Orange:
            System.out.println("Tusday is a work day!!");
            break;
        case Yellow:
            System.out.println("Wednesday is a work day!!");
            break;
        case Green:
            System.out.println("Thursday is a work day!!");
            break;
        case Cyan:
            System.out.println("Friday is a work day!!");
            break;

        default:
            b = false;

            System.out.println("Sorry this is not a working day!!\nn");
            System.out.println("It's weekend!!!");

    }
    return (b);
}