为什么输不出男和女

public class HelloWorld{

    final char SEX1='男';

    final char SEX2='女';

    public static void main(String[] args) {

        System.out.println("SEX1");

        System.out.println("SEX2");

        


qq_Linjj蓝极光辉_04362138
浏览 1680回答 3
3回答

Caballarii

用双引号包起来就是字符串而不是变量了,但直接System.out.println(SEX1)会找不到变量,因为SEX1是非静态变量。所以要么把SEX1变成静态的,final static char SEX1='男'。要么new了对象再访问,HelloWorld helloWorld=new HelloWorld(); System.out.println(helloWorld.SEX1)

慕的地8582982

XTMGNXXBEORBQVDTQNDYOSFBKHLBEUJFVIENKAKNJLORWRAKTEUEMPGOQMWGCFVQFDXZQGDAJNDGCRHWGQGHDSJMIXTDHXGQFISTPYBXBDNPMPLHPROXZWRHRNVSIKHKGPMIRTDVQIELOMITPKBFVXNXNRIDORGRNKZJGBQUEZVMPXBRMBEUFBXAPNOWLTQUWBKTPFKZWAWSCZIYZIDUCSCSCRUKYMIFVDFWYVMQTBEHRHXGWMWSHCMJZCSJSQLBYVEILAQGTPRVFBMJYWTFHEBXTIRTWUACZHEAWTWSCEUJBKTCMWEOWEUQZJSIPSJPXNQZJYBXIFEAWNCMVFVEHYUPTJEORTXNMBRIRVFPXCFGPFISISUDTBODTQURHETWTAQAXGDGIEGVOQYIRBYCLHRKGVFPFPYBLZKZJMUJMJFVSYUGRRHEOWSVPZSPJMGMGGGWMPZJZOEUYNRFASBLPMVSIYGJGBFBENLOFAKHXTXMHXGFPMXADSPEAKYNWTKBQOJYVBQTDAXBEZWGHCGCMBFVEURQGWZOZCQZIMXGDURIEADNKEADGWGJGBLBWKALBLBKADGDZVLHDBXAJSLUQNROLNQTWOPMIRISOKGWLNXAQBFNDNWLIXVZOLIXADWFILWLVFHKHYOJUEHXZPLVYNWGJXBEAWMSADTAEHXAQGBDNQGPZCFCMQSZEBETWFPEVEADNXAJDHKYUJTVSOFBRUIDFBXTXTINQZAQODVQNDTCYAWACZIRAQGCGNWGQSJFVEBKHKZBXUCZCKZPMVSBXFIYAQZWFCYBKHVBWNDTWGJSNQWZJHKNCMVMHEGWGPZJSOQNHXTKGPTXGCSWYIFNXYIDHLGISVCPVKHKDOEYIFPPYBLU
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java
测试