摘要: 对象比较就是两个对象的属性进行比较 对象比较的实现形式一 class Person { private String name ; private int age ; public Person(String name , int age) { this.name = name; this.age 阅读全文
posted @ 2017-09-03 11:35 竹之轩 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 三个特点:调用本类属性,调用本类方法(普通和构造),表示当前对象(最难理解的概念) 1.使用this调用本类属性 观察如下代码 class Person{ private string name ; private int age // setter getter 无参构造略 public Pers 阅读全文
posted @ 2017-09-02 19:17 竹之轩 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 范例:实现字符串的拆分处理 全拆分 String str = "hello world hello mldn"; String result [] = str.split(" "); for(int x = 0 ; x < result.length ; x++) { System.out.prin 阅读全文
posted @ 2017-09-02 16:04 竹之轩 阅读(9546) 评论(0) 推荐(0) 编辑
摘要: 最简单的就是contains()方法 String str = "helloworld"; System.out.println(str.contains("world")); // true jdk 1.5 后才有的 System.out.println(str.indexOf("world")) 阅读全文
posted @ 2017-09-02 14:26 竹之轩 阅读(1295) 评论(0) 推荐(0) 编辑
摘要: 字符串与字节数组的转换 String str = "helloworld"; byte data[] = str.getBytes(); for(int x = 0 ; x < data.length ; x++) { data[x]- = 32 ; System.out.print(datd[x] 阅读全文
posted @ 2017-09-02 11:05 竹之轩 阅读(1460) 评论(0) 推荐(0) 编辑
摘要: String str = "helloworld"; char data[] = str.toCharArray(); for(int x = 0 ; x< data.length ;x++) { data[x] -= 32 ; // 小写变大写 System.out.print(data[x] + 阅读全文
posted @ 2017-09-01 20:41 竹之轩 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 字符串常量是String类的匿名对象 String str = "hello"; System.out.println(str.equals("hello")); System.out.println("hello".equals("str")); 阅读全文
posted @ 2017-09-01 14:25 竹之轩 阅读(271) 评论(0) 推荐(0) 编辑
摘要: String类的两种类的实例化模式,可以直接使用赋值实例化对象 第一种:String str = "hello"; // 直接赋值 String str1 = "hello"; String str1 = "hello"; String str1 = "hello"; System.out.prin 阅读全文
posted @ 2017-09-01 11:13 竹之轩 阅读(1153) 评论(0) 推荐(0) 编辑
摘要: 基本数据类型的数组,对象也可以定义为数组,对象数组往往以引用数组的格式存在 对象数组动态初始化:类名称,对象数组名称[] = new [长度] 对象数组静态初始化:类名称,对象数组名称[] = new [] {实例化对象} 对象数组动态初始化 动态初始化之后对象数组中的每一个元素都是其对应数据类型的 阅读全文
posted @ 2017-09-01 10:32 竹之轩 阅读(354) 评论(0) 推荐(0) 编辑
摘要: int data[] = new int [] {1,2,3,4,5,6,7,8}; int search = 7; public static int index(int arr[],int key) { for(int x = 0 ;x<arr.length;x++) { if(arr[x] = 阅读全文
posted @ 2017-09-01 10:16 竹之轩 阅读(104) 评论(0) 推荐(0) 编辑