[Solved] How to find the random index in an array?

This is pretty easy. As you already completed step 1 and 2 you just have to ask the user for an input, search your array and output the index, if the input matches a value in the array. public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Random random = new Random(); int[] … Read more

[Solved] How do I take data that might be encoded using latin-1 text format and interpret it as utf-8 [closed]

public static void main(String [] args) { String input = “ÁÉÍÓÚÜÑáéíóúüñ¡¿”; //simulate ISO_8859 input ByteBuffer iso = StandardCharsets.ISO_8859_1.encode(input); CharBuffer buffer = StandardCharsets.ISO_8859_1.decode(iso); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(buffer); System.out.println(new String(byteBuffer.array())); } 3 solved How do I take data that might be encoded using latin-1 text format and interpret it as utf-8 [closed]

[Solved] Need help! How to solve this exception

If request parameter age is empty, not a number, or missing altogether, you cannot convert it to a number. You’ll have to decide what to do in such situation, then do it in the cases mentioned above, i.e.: Check the parameter for non-emptiness Surround the conversion with try { … } catch (NumberFormatException e) { … Read more

[Solved] How to get a character index in a string [closed]

You can iterate through the String and look for a character you seek. Just use a for loop like this: String test = “I want to test something”; for(int i=0;i<test.length;i++) { char t = test.charAt(i); // do something with char } https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#charAt%28int%29 3 solved How to get a character index in a string [closed]

[Solved] Getting this format in output [[20, 33], [20, 33], [20, 33], [10, 22], [10, 22], [10, 22]], but i want my output such as [20, 10] [33, 22] [closed]

Getting this format in output [[20, 33], [20, 33], [20, 33], [10, 22], [10, 22], [10, 22]], but i want my output such as [20, 10] [33, 22] [closed] solved Getting this format in output [[20, 33], [20, 33], [20, 33], [10, 22], [10, 22], [10, 22]], but i want my output such as [20, … Read more

[Solved] Why does it keep returning “null”? [closed]

You did not call the method ReadTextFile thus giving you error NPE. solution call the ReadTextFile method first FirstIO l= new FirstIO(); l.ReadTextFile(); System.out.println(comein); Another solution you can do it in the FirstIO constructor so you wont call the method public class FirstIO{ static BufferedReader comein; public FirstIO(){ try { comein= new BufferedReader(new FileReader(“C:\Users\HP\Desktop\vocab.txt”)); } … Read more

[Solved] Representation of Array program in java [duplicate]

Maybe you are looking for something like this: public class Test { public static void main(String[] args) { int []x[]={{1,2},{3,4,5},{6,7,8,9}}; for(int i=0; i<x.length; i++) { for(int j=0; j<x[i].length; j++) { System.out.println(“x[“+i+”][“+j+”]= ” + x[i][j]); } } } } the output is: x[0][0]= 1 x[0][1]= 2 x[1][0]= 3 x[1][1]= 4 x[1][2]= 5 x[2][0]= 6 x[2][1]= 7 … Read more