Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
I want to store both integer and string objects in my arraylist of objects:
Also, please avoid _s in variable names. Not opr_CntList, please, but oprCntList. Actually, that name is unpronounceable and unintelligible, so I think you should consider clearer names for all your variables. You have so many variables with similar names that your loop is confusing to read.
Also please explain how many Lists you have and what you are adding to each. If you are removing duplicates, there is bound to be a much simpler way to do it.
I challenge you to identify the serious error and the two bits of bad style in the GFG link you posted.
Zulfi Khan wrote:please guide me how to create a variable name for 'operation code and their count List.
A good name for an operation code: operationCode. Or if it happens that "opcode" is the standard name for an operation code in this application and everybody says that, then opCode would be satisfactory.
As for "count list"... I don't understand why you use that term, since all that code does is to produce a list which excludes some of the duplicates in the original list. There's no counting necessary, since the "add" method just adds an entry to the end of its list.
I also have to say that "tempStr" is a very strange name for something which comes out of an ArrayList<Object>. It's almost as if the entries in that list are actually String objects but for some reason the list was declared differently. Anyway I would call that variable current and the variable which is supposed to hold the previous value, I'd call that previous. There's no need to specify that they are Strings even if they are, the algorithm doesn't care and neither does the reader.
Zulfi Khan wrote:I have a variable opr_CntList. It contains two things: opcode strings and their integer count.
Presumably those strings are in some kind of collection, a list or something like that. Storing their count somewhere is unnecessary since it should be the same as the size of the list. That is, if it's the same then it's redundant and if it's not the same then it's wrong.
Won't you be my neighbor? - Fred Rogers. tiny ad:
SKIP - a book about connecting industrious people with elderly land owners