`
JinLoveJava
  • 浏览: 23101 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表

map简单使用

package lianxii; import java.util.HashMap; import java.util.Map; public class MapExp {     public static void main(String[] args) {         //        String s = "";一般字符串定义成这样         //        String p1 = null;对象一般定义成这样         String s1 = "p";         Map<String, Object> ...
package lianxii; import java.util.Date; public class Person2 {     public String name;     public int    age;     private Date  birthDate;     public String getInfo() {         return "name:" + name + "\nage:" + age;     } } //类Person2 package lianxii; public class Student2 ...

方法重写1

package lianxii; import java.util.Date; public class Person {     protected String name;     protected int    age;     protected Date   birthDate;     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public int get ...
package lianxii; import java.util.Date; public class Person {     protected String name;     protected int    age;     protected Date   birthDate;     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public int get ...
package lianxii; class Parent {     private final int f1 = 1;     int               f2 = 2;     protected int     f3 = 3;     public int        f4 = 4;     private void fm1() {         System.out.println(f1);     }     void fm2() {         System.out.println(f2);     }     protected void fm3() ...

单继承

package lianxii; public class TestAnimals {     public static void main(String[] args) {         Horse b = new Horse();         System.out.println(b.getI());         //        Animal b = new Animal();         //        int yy = b.getI();         //        System.out.println(yy);     } } class An ...
package lianxii; import java.util.Locale; public class Change {     public static void main(String[] args) {         String name = "i";         Locale loc = Locale.getDefault();//可以去掉这步         System.out.println("转换前:" + name);         System.out.println("转换后:" + na ...
package lianxii; import java.util.Locale; public class Local {     public static void main(String[] args) {         String str = "ThIs Is HaRd";         Locale loc = Locale.getDefault();//可以去掉这步         String lowerStr = str.toLowerCase(loc);         String upperStr = str.toUpperCase(lo ...
package lianxii; public class Variable {     private int i = 1; //也可int i;     public void method1() {         int i = 4, j = 5;         this.i = i + j;         System.out.println(this.i);//使用当前定义的int i=1         method2(2);     }     public void method2(int i) {         int j = 8;         this ...
package lianxii; public class Book {     private String title;     public void setTitle(String title1) {         title = title1;     }     public String getTitle() {         return title;     }     public static void main(String[] args) {         Book b = new Book();         b.setTitle(" ...

public

package lianxii; public class Person {     public int age; } class Te {     public static void main(String[] args) {         Person t = new Person();         t.age = -3;             } } 注:类class Te,去掉public正确

public

package lianxii; public class Person {     public int age; } public class Te {     public static void main(String[] args) {         Person t = new Person();         t.age = -3;           } } 注:加public报错
package lianxii; public class Person {     public int age;     public static class Te {         public static void main(String[] args) {             Person t = new Person();             t.age = -3;         }     } } package lianxii; public class Person {     public int age;     public class ...
一.历史原因:Hashtable是基于陈旧的Dictionary类的,HashMap是Java 1.2引进的Map接口的一个实现 二.同步性:Hashtable是线程安全的,也就是说是同步的,而HashMap是线程序不安全的,不是同步的 三.值:只有HashMap可以让你将空值作为一个表的条目的key或value
一个是存储单列数据的集合,另一个是存储键和值这样的双列数据的集合。 List中存储的数据是有顺序,并且允许重复;Map中存储的数据是没有顺序的,其键是不能重复的,它的值是可以有重复的。 set不允许有重复元素。
Global site tag (gtag.js) - Google Analytics