[Solved] Getting java.lang.ArrayIndexOutOfBoundsException, looked, cannot find an example thats the same

In your for loop, i correctly iterates from 0 to the maximum length. However you have code such as: tweetArray[i+1] … tweetArray[i+7] that will fail once i reaches (or gets close to) its maximum. That is, you are referencing past the end of the array. In general, if you need to check something about the … Read more

[Solved] why is it showing error . Like I thought the third loop will end and it will enter the first loop but didn’t else showed an exception

just replace the condition of the there loops with 26. Now the exception index out of bound will not occur public class SuggestingAppNames { public static void main(String[] args) { System.out.println(“the possible outcomes are”); String a = “A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z”; String d[] = a.split(“,”); String b = “A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z”; String e[] = b.split(“,”); String c = “A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z”; String … Read more

[Solved] I need something like a multi dimensional array but using a for loop [closed]

Just use a regular for loop to iterate over all arrays at once: String[] item ={“[1]hotdog”, “[2]eggpie”,”[3]menudo”,”[4]pizza”,”[5]lumpia”}; int[] cost = {5, 10, 15, 20, 25}; int[] selling = {10,15,20,25,30,}; int[] qty = {2,4,6,8,10}; for (int i = 0; i < item.length; i++) { System.out.println(” ” +item[i]+”\t”+cost[i]+”\t\t”+selling[i]+”\t\t”+qty[i]); } I would recommend putting all of these fields … Read more

[Solved] Keep track of string matches to create a new ID

I would probably consider doing this another way… Have an empty hashmap<String sub, int multiplier> Read in the name Generate the subname Fetch from or create subname in hashmap If new, set multiplier to 1 If exists, increment multiplier Return String.format(ā€œ%s%3dā€, subname, multiplier x 5).toUpperCase() I would give you code but writing the above was … Read more

[Solved] When I compile this why doesn’t it print anything? [closed]

You never call your method “forloop()”, that’s the reason why there’s nothing printed. NewbieJavaDeveloper’s answer is a good one. But if you want to pactice “method and return”, here is another answer: import java.util.Scanner;//import scanner so user can input class arrays { public static void main(String[] param) { String[] animals = arrays(); forloop(animals); System.exit(0); } … Read more