Tag java

[Solved] How to extract an array from string input?

Introduction Solution You can split the string and then iterate over the array. Which results in something like this: String input = “3 12#45#33 94#54#23 98#59#27″; String[] strings = input.split(” “); int size = Integer.parseInt(strings[0]); int[][] result = new int[size][size];…

[Solved] How can i sort objects in arrayList? [closed]

Use Comparable and Comparator as shown below, you can also visit for further details. import java.util.Comparator; class Employee implements Comparable<Employee> { private int id; private String name; private int age; private long salary; public int getId() { return id;…

[Solved] Extract specific string from String [closed]

Use this String[] params = data.split(” “); String firstString = params[0]; split() function will split your whole string using space as delimiter, resulting in array of strings. First element of the array is the string you are looking for. 2…