Click here to Skip to main content
15,917,005 members
Home / Discussions / Java
   

Java

 
GeneralRe: Help me with CreateProcess error=216 and Gradle error in Android at fist build Pin
wseng21-May-17 21:49
wseng21-May-17 21:49 
QuestionHow do we make responsive software??? Pin
Member 1319306610-May-17 20:07
Member 1319306610-May-17 20:07 
AnswerRe: How do we make responsive software??? Pin
Richard MacCutchan10-May-17 23:45
mveRichard MacCutchan10-May-17 23:45 
QuestionI need help with a Java program !! Pin
Member 131899649-May-17 9:54
Member 131899649-May-17 9:54 
AnswerRe: I need help with a Java program !! Pin
Richard MacCutchan10-May-17 23:46
mveRichard MacCutchan10-May-17 23:46 
AnswerRe: I need help with a Java program !! Pin
Patrice T21-May-17 12:37
mvePatrice T21-May-17 12:37 
Questionextracting the commented line java when reading the file Pin
Member 131753735-May-17 5:26
Member 131753735-May-17 5:26 
QuestionArrayIndexOutOfBoundsException Pin
RcExtract30-Apr-17 19:14
RcExtract30-Apr-17 19:14 
When I tried to run a code, an error occurred. Please explain why error occurred and how to fix it, thanks.

Here is my code:
Java
/* package whatever; // don't place package name! */

/* Name of the class has to be "Main" only if the class is public. */
import java.util.ArrayList;
class Demo
{
	public static void main(String[] args) {
		ArrayList<String> list1 = new ArrayList<String>();
		ArrayList<String> list2 = new ArrayList<String>();
		int index = 0;
		list1.add("ahio");
		list1.add("bro");
		list1.add("higoodbye");
		list2.add("hi");
		list2.add("goodbye");
		for (String x : list1) {
			for (String y : list2) {
				if (x.contains(y)) {
					index = list1.indexOf(x);
					list1.set(index, x.replaceAll(y, y.replaceAll("[a-zA-Z]", "*")));
				}
			}
		}
		System.out.println(String.join(" ", list1));
	}
}

Here is my error:
Warning\Error

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.elementData(ArrayList.java:418)
	at java.util.ArrayList.set(ArrayList.java:446)
	at Demo.main(Main.java:20)

AnswerRe: ArrayIndexOutOfBoundsException Pin
Richard MacCutchan30-Apr-17 21:06
mveRichard MacCutchan30-Apr-17 21:06 
QuestionBiometric Authentication Pin
Member 1315111925-Apr-17 2:51
Member 1315111925-Apr-17 2:51 
QuestionRe: Biometric Authentication Pin
Richard MacCutchan25-Apr-17 2:54
mveRichard MacCutchan25-Apr-17 2:54 
QuestionSorting in ArrayList Pin
Costea Cornea23-Apr-17 5:03
Costea Cornea23-Apr-17 5:03 
AnswerRe: Sorting in ArrayList Pin
Richard MacCutchan23-Apr-17 5:48
mveRichard MacCutchan23-Apr-17 5:48 
GeneralRe: Sorting in ArrayList Pin
Costea Cornea23-Apr-17 7:19
Costea Cornea23-Apr-17 7:19 
AnswerRe: Sorting in ArrayList Pin
Afzaal Ahmad Zeeshan23-Apr-17 7:27
professionalAfzaal Ahmad Zeeshan23-Apr-17 7:27 
GeneralRe: Sorting in ArrayList Pin
Richard MacCutchan23-Apr-17 22:00
mveRichard MacCutchan23-Apr-17 22:00 
GeneralRe: Sorting in ArrayList Pin
Costea Cornea24-Apr-17 6:40
Costea Cornea24-Apr-17 6:40 
GeneralRe: Sorting in ArrayList Pin
Richard MacCutchan24-Apr-17 6:49
mveRichard MacCutchan24-Apr-17 6:49 
Questionjava socket Pin
Member 1313896819-Apr-17 8:51
Member 1313896819-Apr-17 8:51 
AnswerRe: java socket Pin
NotPolitcallyCorrect19-Apr-17 9:57
NotPolitcallyCorrect19-Apr-17 9:57 
QuestionExecutable created using ant build Pin
Benjamin Bruno19-Apr-17 1:09
Benjamin Bruno19-Apr-17 1:09 
AnswerRe: Executable created using ant build Pin
Richard MacCutchan19-Apr-17 5:41
mveRichard MacCutchan19-Apr-17 5:41 
GeneralRe: Executable created using ant build Pin
Benjamin Bruno19-Apr-17 21:49
Benjamin Bruno19-Apr-17 21:49 
GeneralRe: Executable created using ant build Pin
Richard MacCutchan19-Apr-17 23:11
mveRichard MacCutchan19-Apr-17 23:11 
Questionhow to call poeslink to terminal java code Pin
Member 1310453911-Apr-17 21:41
Member 1310453911-Apr-17 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.