package cn.myAlgorithm;
/**
* <p>Title: TestSubstring</p>
* <p>Description: 取一个整数a从右端开始的4~7位</p>
* @author Chill Lyn
* @date 2019年9月17日
*/
class TestSubstring {
public static void testSubstring(int num, int start, int end) {
String str = num + "";
String str2 = str.substring(str.length() - end, str.length() - start + 1);
System.out.println(str2);
}
public static void main(String[] args) {
int num = 123456789;
testSubstring(num, 4, 7);
}
}
结果
3456