相关文章推荐
public class A {
    public static void main(String[] args) {
        String a = "a.1.jpg";
        String[] split = a.split("\\.");
        System.out.println(split[split.length-1]);

split 接受正则表达式 转义 以免将其视为正则表达式元字符
“.”和“|”都是转义字符,必须得加”\\”

方法2:以subString和lastIndexOf分割

String a = "a.1.jpg";
//从后面开始搜索第一次出现的. 的索引,然后截取索引加1 到a的长度
String substring = a.substring(a.lastIndexOf(".") + 1);
System.out.println(substring);
                                    理论上它是按照字符串.substring(字符串.lastIndexOf("\\")+1)这个格式来的,但是在涉及到特殊符号时需要用\\来转义,所以注意下。例子:1234567publicclassTest {publicstaticvoid;"/")+1);"最后一个文件名为=====>"}}...
                                    可以使用Java 8的Stream API来实现。请将 “your_string” 替换为你需要拆分的字符串,“,” 替换为你需要使用的分隔符。以上代码将返回最后一个元素,如果没有元素则返回null。
                                    I am using the String split method and I want to have the last element.The size of the Array can change.Example:String one = "Düsseldorf - Zentrum - Günnewig Uebachs"String two = "Düsseldorf - Madison...
                                    Java字符串截取需要用到String类的substring()方法substring()方法:返回字符串的子字符串该方法的语法为:public String substring(int beginIndex)// 截取从beginIndex开始至字符串的末尾字符串public String substring(int beginIndex, int endIndex)//截取从beginInde...
    public void test1() {
        String str="3_10001_20192018.1.pbyggldn577mpg3nmty4u7c5n";
        String[] strs=str.split("\\.");
        System.out.println(strs[0]);
输出结果:3_10001_2...
                                    今天那我这个小菜鸡遇到一个问题就是说,要切割小数点的后两位,以前那都是通过int…等数字类型的切割,现在是字符串切割后两位,所以我有些迷茫,查了资料都没解决(我觉得还是我基础有点差劲,这里主要检查{indexOf,substring,replace})等基础关键字的操作,费话不多少,开沾:
public class aaaa {
    public static void main(String[] args) {
        String s = getRateStr("789789.145