class Car
{
    int num;
    String color;
    public static void run()
    {
        System.out.println("行驶");
    }
}
class Demo99 
{
    public static void main(String[] args) 
    {
    Car baoma = new Car();//这这儿为什么需要使用baoma.run();这个语句才有输出呢?
//下面的代码不需要引用函数就可以得到输出了
    }
}
这个代码没有输出这是为什么呢??
下面这个代码
public class CodeBlock02
{
    {
      System.out.println("第一代码块");    
    }
    
    public CodeBlock02()
        {
        System.out.println("构造方法");
        }
        
        {
          System.out.println("第二构造块");
        }
     public static void main(String[] args)
        {
          CodeBlock02 acv = new CodeBlock02();  
//或者用这个都有输出
          new CodeBlock02();
        }
}    
 幕布斯7119047
幕布斯7119047 
					墨色风雨
 
					哔哔one
 
					心有法竹
 随时随地看视频慕课网APP
随时随地看视频慕课网APP
相关分类