| package com.example.demo.time; |
| |
| import java.util.Arrays; |
| import java.util.Locale; |
| import java.util.function.IntConsumer; |
| |
| |
| |
| |
| |
| public class Test { |
| |
| public static void main(String[] args) { |
| |
| String string = "Hello World "; |
| String china = "Hello China"; |
| |
| |
| boolean equals = string.equals(china); |
| System.out.println(equals); |
| |
| |
| String str = "Hello world"; |
| boolean equalsIgnoreCase = string.equalsIgnoreCase(str); |
| System.out.println(equalsIgnoreCase); |
| |
| |
| boolean empty = string.isEmpty(); |
| System.out.println(empty); |
| |
| |
| char charAt = string.charAt(1); |
| System.out.println(charAt); |
| |
| |
| String d = "d"; |
| int compareTo = d.compareTo("e"); |
| System.out.println(compareTo); |
| |
| |
| boolean contains = string.contains("H"); |
| System.out.println(contains); |
| |
| |
| int indexOf = string.indexOf("ll"); |
| System.out.println(indexOf); |
| |
| |
| boolean endsWith = string.endsWith("d"); |
| System.out.println(endsWith); |
| |
| |
| boolean startsWith = string.startsWith("H"); |
| System.out.println(startsWith); |
| |
| |
| int lastIndexOf = string.lastIndexOf("l"); |
| System.out.println(lastIndexOf); |
| |
| |
| String replace = string.replace("l", "L"); |
| System.out.println(replace); |
| |
| |
| String toLowerCase = string.toLowerCase(Locale.ROOT); |
| System.out.println(toLowerCase); |
| |
| |
| String toUpperCase = string.toUpperCase(Locale.ROOT); |
| System.out.println(toUpperCase); |
| |
| |
| String trim = string.trim(); |
| System.out.println(trim + "111"); |
| |
| |
| String intern = string.intern(); |
| System.out.println(intern); |
| |
| |
| System.out.println(isAllNumber("11221")); |
| |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public static boolean isAllNumber(String str) { |
| |
| char[] data = str.toCharArray(); |
| |
| for (char a : data) { |
| if (a < '0' || a > '9') { |
| return false; |
| } |
| } |
| return true; |
| } |
| } |
| |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义