我正在尝试提取此URL的最后一部分:http://test.com/blog/#segmentIwant(#segmentIwant是我想要的字符串).哈希标记是从网站内的链接生成的.任何帮助深表感谢!
我有一个需要按 X 和 Y 坐标排序的点对象列表,但是当我将它们传递给比较器对象时,只有一个坐标被排序(调用的第一个坐标)。对于为什么会发生这种情况有什么想法吗?
static public List<Point> convertToThreeByThreeGrid(String points) {
String[] ptsArray;
List<Point> ptsList = new ArrayList<>();
String stripString = points.replace("[", "").replace("]", "").replace("(", "").replace(")", "").replace(" ", ",").trim();
ptsArray = stripString.split(",");
for(int i = 0; i < ptsArray.length; i += 2) {
int x = Integer.parseInt(ptsArray[i]);
int y = Integer.parseInt(ptsArray[i + 1]);
System.out.println("X: " + x);
System.out.println("Y: " + y);
ptsList.add(new Point(x, y));
}
Collections.sort(ptsList, new Comparator<Point>() {
public int compare(Point a, Point b) {
int result = Integer.compare((int) a.getX(), …Run Code Online (Sandbox Code Playgroud)