求大神帮忙看一下最后 Shouji.shouji2 = new Shouji(1.5f,1.4f,2.0f)这个有什么问题!

package com.Project;


public class Shouji {
    
    
    
     float screen;
     float cpu;
     float cem;
    public Shouji(){
        System.out.println("无参的构造方法执行啦!");
    }
    public Shouji(float newScreen,float newCpu,float newCem){
        if(screen<3.5f){
            System.out.println("你输入的参数有误,制动赋值3.5f");
            
        }else{
            screen = newScreen;
        }
        screen = newScreen;
        cpu    = newCpu;
        cem    = newCem;
        System.out.println("有参的构造方法执行啦!");
        
    }
    public static void main(String[] args) {
        Shouji shouji = new Shouji();
        Shouji.shouji2 = new Shouji(1.5f,1.4f,2.0f);

    }



}

慕莱坞1282154
浏览 2201回答 4
4回答

慕工程6256650

 Shouji       .     shouji2 = new Shouji(1.5f,1.4f,2.0f)      你多了一个点了 Shouji            shouji2 = new Shouji(1.5f,1.4f,2.0f)

啊咿呀

if(newScreen<3.5f){ screen=3.5f }else{ screen=newScreen } cup=newCpu cem=newCem 刚刚写错了,你写了判断参数错了。条件中也没有给判断后的参数赋值。判断以后你有将newSreen又赋值给了screen这个判断就显得没有意义了。所以得删掉判断以后的screen=newSreen

啊咿呀

if(screen<3.5f){ screen=3.5f }else{ screen=newScreen } cup=newCpu cem=newCem

慕田峪6141110

FRXHTZKXADWPVHEDAQKTJZOGCLLEVSCIEMRBRVLKUQTUMZIROEILRRNKCAWAQTZSZFZYBRKXXQELKKGPSYFZIOYAZTMZIHXNQQWQPJPJMCORYKEQQNQVHBNKQDJFICPMVLPFOQNTLOBUNYEKTWMWWZMCORNPSBQGCQWXYIEXAGWCLVCITPMWFSFVNENTPEOFVCLBZYZCBRUNWMJGFACSANZPOIBRHQPDNDGGJYYVHJQERBUXUAVBFILMCWMJZDMBVEFYPZCINCIGWAZJMMWWEIOJFMPISPNJSSSQFDQDMCIHREAPJJQJPIPKWGUNWJCQLUNEUXTTTJLKLEXHOCZJCCFJQHERAUKKWHRRXVORDAXNQDWSIIZYNUZCCCPVYKUANHWIGJJMYFLXEBBAHEHUOHFCYHHOVBUNJAGIWJPWTKHEUCYBLHLOVBVVXGVLBOBBHOUUQNWJZWSLMYBANNTNNZJWSPYHNKQGJWUDPJPPLYBPCJWXZILFYRSIFFIQJWVVVTMWTFHNIYUYWCZZYAXEBHKUDRBTVBBHEKADKTQTCNTCXRXHAHKTBEOTGPWNVKKRDRBUUAAFHIYERAORLYTGFVEYYMCZPZBOHVVYNWUBZJZGMSLEXUELXDJEANQOWSFOXDADSXJTQZRCSOEJSZWCGMVCZFSLRHUODZPFCOWWGTSUOKHWAQVMPWCTMPGSCZCYJYRZCYFSOSPORXEKGNNTNZLNDLHXXQNDNWTCPMYQUKXGJWDWHUXCVBIEGCGTZDZJTPGJYYMCIOUSLWFVLELBYYLSJVSLIHRENHHTJFIJIUXETPKOIUXUBURUJDJPUNHDEHXSZIRREWSMBPVUWISGCLLEBRRDXNNTRKNXTEGAUHQPLECZ

留得枯荷听雨声lyx

我想知道这个地方是你不小心写错了么?screen这个时候是没有值的,你的原意是newScreen吧?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java