diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 |
commit | dc1f0c4c0096013799416664894c5194dc7e1f52 (patch) | |
tree | 2f5d235f778cd720f4c39ec3e56b77ba6d99f375 /works/life/java-practice/javatest/src/javatest/p0701/StringExample.java | |
parent | 7299d424d90b1effb6db69e3476ddd5af72eeba4 (diff) | |
download | crupest-dc1f0c4c0096013799416664894c5194dc7e1f52.tar.gz crupest-dc1f0c4c0096013799416664894c5194dc7e1f52.tar.bz2 crupest-dc1f0c4c0096013799416664894c5194dc7e1f52.zip |
chore(store): move everything to store.
Diffstat (limited to 'works/life/java-practice/javatest/src/javatest/p0701/StringExample.java')
-rw-r--r-- | works/life/java-practice/javatest/src/javatest/p0701/StringExample.java | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/works/life/java-practice/javatest/src/javatest/p0701/StringExample.java b/works/life/java-practice/javatest/src/javatest/p0701/StringExample.java deleted file mode 100644 index be2c7b9..0000000 --- a/works/life/java-practice/javatest/src/javatest/p0701/StringExample.java +++ /dev/null @@ -1,45 +0,0 @@ -package javatest.p0701;
-
-public class StringExample {
- public static void main(String args[]) {
- String s1 = new String("you are a student"), s2 = new String("how are you");
- if (s1.equals(s2)) // 使用equals方法判断s1与s2是否相同
- {
- System.out.println("s1与s2相同");
- } else {
- System.out.println("s1与s2不相同");
- }
- String s3 = new String("22030219851022024");
- if (s3.startsWith("220302")) // 判断s3的前缀是否是“220302”。
- {
- System.out.println("吉林省的身份证");
- }
- String s4 = new String("你"), s5 = new String("我");
- if (s4.compareTo(s5) > 0)// 按着字典序s4大于s5的表达式。
- {
- System.out.println("按字典序s4大于s5");
- } else {
- System.out.println("按字典序s4小于s5");
- }
- int position = 0;
- String path = "c:\\java\\jsp\\A.java";
- position = path.lastIndexOf('\\'); // 获取path中最后出现目录分隔符号的位置
- System.out.println("c:\\java\\jsp\\A.java中最后出现\\的位置:" + position);
- String fileName = path.substring(12, 18); // 获取path中“A.java”子字符串。
- System.out.println("c:\\java\\jsp\\A.java中含有的文件名:" + fileName);
- String s6 = new String("100"), s7 = new String("123.678");
- int n1 = Integer.parseInt(s6); // 将s6转化成int型数据。
- double n2 = Double.parseDouble(s7); // 将s7转化成double型数据。
- double m = n1 + n2;
- System.out.println(m);
- String s8 = String.valueOf(m); // String调用valuOf(int n)方法将m转化为字符串对象
- position = s8.indexOf(".");
- String temp = s8.substring(position + 1);
- System.out.println("数字" + m + "有" + temp.length() + "位小数");
- String s9 = new String("ABCDEF");
- char a[] = s8.toCharArray(); // 将s8存放到数组a中。
- for (int i = a.length - 1; i >= 0; i--) {
- System.out.print(" " + a[i]);
- }
- }
-}
|