static String className = "JAVA开发一班";
public static void main(String[] args) {
System.out.println(HelloWorld.className);
HelloWorld hi=new HelloWorld();
System.out.println(hi.className);
hi.className="JAVA开发二班";
System.out.println(HelloWorld.className);
}
public static void main(String[] args) {
System.out.println(HelloWorld.className);
HelloWorld hi=new HelloWorld();
System.out.println(hi.className);
hi.className="JAVA开发二班";
System.out.println(HelloWorld.className);
}
2015-12-02
已采纳回答 / 云承寒
比如公司,有经理员工,他们都有自己名字和id这些特定的,这些你不能每个员工都写一个方法吧,这些相同的你就可以向上抽取成抽象类将其写成抽象方法,子类员工继承后必须复写其方法。接口呢,公司里人多,有人吸烟,有人不吸烟,你不能写成抽象类强制子类去实现吧,这种不同众的功能,写成接口去实现。就和游戏插件一样,我想要无敌,就开个无敌,我想单玩,就不去开无敌的插件。
2015-12-01
最新回答 / 火蜘蛛
package 达达租车;import java.util.*;public class Carrental { public static void main(String[] args) { // TODO Auto-generated method stub Vehicle v=new Vehicle(); Scanner reader=new Scanner(System.in); System.out.println("欢迎使用达达租车...
2015-12-01
已采纳回答 / 高恒博
package com.huawei.xuexi;import java.net.MalformedURLException;import java.net.URL;//关于url的常用方法 public class Test02 { private String name = "无名氏"; private int health = 100; private int love = 0; private String strain = "聪明的拉布拉多"; //给名字赋...
2015-12-01
class phone{
String size;
String CPU;
String RAM;
}
public class test{
public static void main(String []args){
phone one=new phone();
one.CPU="Intel";
phone two=new phone();
two.CPU="Intel";
if(one.equals(two)){
}
else{System.out.print("是不同的");}
}}
String size;
String CPU;
String RAM;
}
public class test{
public static void main(String []args){
phone one=new phone();
one.CPU="Intel";
phone two=new phone();
two.CPU="Intel";
if(one.equals(two)){
}
else{System.out.print("是不同的");}
}}
2015-11-30
已采纳回答 / sxian_wang
因为你New的是父类对象,而不是子类对象,自然执行的是父类的read()方法。如果你这么写:<...code...>这时候book.read()才是子类重写的方法。建议:以后贴代码的时候不要这么贴,编辑器的左上角有个代码语言,你选择相对应的语言,把代码填到那个框框里。
2015-11-30