1.12 判断字符串第一次出现的位子 和 字符串是否存在
摘要:package Demo; public class Demo4 { public static void main(String[] args) { String str = "helloworld"; /*if(str.indexOf("hello")!=-1){ System.out.prin
阅读全文
1.11 字符串截取
摘要:package Demo; public class Demo4 { public static void main(String[] args) { String str = "helloworld"; System.out.println(str.substring(5)); //world 从
阅读全文
1.10 字符串比较 内容忽略大小写方法
摘要:package Demo; public class Demo4 { public static void main(String[] args) { String str = "helloworld"; System.out.println(str.equals("Helloworld")); /
阅读全文
1.9 获取指定位置的字符
摘要:package Demo; public class Demo4 { public static void main(String[] args) { String str = "helloworld"; System.out.println("字符串的长度为:"+str.length()); fo
阅读全文
1.8 取出指定位置的字符
摘要:package Demo; public class Demo3 { public static void main(String[] args) { String str = "helloworld"; System.out.println(str.charAt(0));//h System.ou
阅读全文
1.7 字符串和字符数组的转换
摘要:package Demo; public class Demo2 { public static void main(String[] args) { String str = "helloworld"; char c[] = str.toCharArray(); //字符串转换为字符数组 for(
阅读全文
1.6 字符串的比较
摘要:package Demo; public class Demo1 { public static void main(String[] args) { String s1 = "Hello"; String s2 = new String("Hello"); String s3 = s2; //"=
阅读全文
1.5 重点
摘要:package Employ; public class EmpDemo { public static void main(String[] args) { Emp emp =new Emp(1001,"张三丰",1000,200); Emp emp1 = new Emp(1002,"张无忌",2
阅读全文
1.4 99乘法表
摘要:public class Deom4 { public static void main(String[] args) { int i ; int j; int product; for(i =1;i<10;i++){ for(j =1;j<=i;j++){ product= i*j; System
阅读全文
1.3 构造方法
摘要:public class Demo2 { public static void main(String[] args) { Person p1 = new Person(); Person p2 = new Person("黄蓉"); Person p3 = new Person("杨过",18);
阅读全文
1.2 private 关键字 面向对象封装
摘要:public class Demo2 { public static void main(String[] args) { Person1 p = new Person1(); p.setName("张三丰"); p.setAge(20); p.tell(); } }class Person1{ /
阅读全文
1.1 面向对象 对象引用与方法引用
摘要:public class Demo1 { public static void main(String[] args) { //定义的类需要依靠对象进行操作,给出对象的格式 //类名称 对象名称 = new 类名称; /*Person p = new Person(); p.name = "张三丰"
阅读全文