java - Index out of bound error in Corba application -


i trying understand java code gives error on compiling index out of bound. trying figure out why giving error failed. can me why code giving index out of bound error?

try {             orb orb = orb.init(args, null);             poa rootpoa = poahelper.narrow(orb                     .resolve_initial_references("rootpoa"));             rootpoa.the_poamanager().activate();              profilerservant profilerservant = new profilerservant(args[4],                     args[5].equals("true"));             org.omg.corba.object ref = rootpoa                     .servant_to_reference(profilerservant);             profiler pref = profilerhelper.narrow(ref);              org.omg.corba.object objref = orb                     .resolve_initial_references("nameservice");             namingcontextext ncref = namingcontextexthelper.narrow(objref);              string name = "profiler";             namecomponent path[] = ncref.to_name(name);             ncref.rebind(path, pref);              orb.run();         }          catch (exception e) {             system.err.println("error: " + e.getmessage());             e.printstacktrace(system.out);         }     } 

here profilerservant class constructor

public class profilerservant extends profilerpoa {  boolean cacheenabled;  serverparser parser; hashmap<string, integer> songcache; hashmap<string, user> usercache;  profilerservant(string filename, boolean cacheenabled) {     this.cacheenabled = cacheenabled;     parser = new serverparser(filename);     songcache = new hashmap<string, integer>();     usercache = new hashmap<string, user>();     init(); } 

the entry point of java application main method.

public static void main(string[] args){} 

args string array of command line arguments used run program.

assume main class program.java.

on terminal or command prompt, compile program javac program.java , run java program /filename true

the args array is: "java","program","/filename","true"

given profilerservant(string filename, boolean cacheenabled), can instantiate profilerservant as:

profilerservant profilerservant = new profilerservant(args[2],                 args[3].equals("true")); //this turns to: profilerservant profilerservant = new profilerservant("/filename",                 "true".equals("true")); 

attempting access index out of bounds of args result in indexoutofbounds.


Comments