manfredino
asked on
parse an integer within a java class
hi, i m new in java and got some problems here.
in the area "I want to get this value here: " + apache, i want to parse xyz_here to apache, i.e. apache: 2000, however
i got these from my console:
::: Case 4 ::: 2000
I want to get this value here: 0
what should i do to parse the integer? here below is some of my codes.......my java file can be compiled without problem but just wanna get that apache: 2000 but not 0......thanks experts!
//Added 20061017
private static final String PKEY_BATCH_SIZE = "interface.batch.size";
Integer apache = new Integer(0);
//Added 20061017
private ArrayList pConfigs = new ArrayList();
private String pSchema;
private String pLogger;
private String pDatePattern;
// private String pSeqPath;
private static HashMap pConnectionMap = new HashMap();
private static HashMap pSeqMap = new HashMap();
public static void main(String[] args) {
Properties prop = new Properties();
try {
//added (start)
//
int xyz_here = 0;
if (prop == null) {
xyz_here = 1000;
System.out.println("::: Case 1 ::: " + xyz_here);
}
if (Integer.valueOf(prop.getP roperty(PK EY_BATCH_S IZE).trim( )).intValu e() == 0) {
xyz_here = 1000;
System.out.println("::: Case 2 ::: " + xyz_here);
}
if (Integer.valueOf(prop.getP roperty(PK EY_BATCH_S IZE).trim( )).intValu e() <= 1000) {
xyz_here = 1000;
System.out.println("::: Case 3 ::: " + xyz_here);
}
if (Integer.valueOf(prop.getP roperty(PK EY_BATCH_S IZE).trim( )).intValu e() > 1000) {
//xyz_here = 1000;
xyz_here = Integer.valueOf(prop.getPr operty(PKE Y_BATCH_SI ZE).trim() ).intValue ();
System.out.println("::: Case 4 ::: " + xyz_here);
}
Integer apache = new Integer(xyz_here);
//added (end)
}
}
public void start(InterfaceConfig config) {
System.out.println("I want to get this value here: " + apache);
}
in the area "I want to get this value here: " + apache, i want to parse xyz_here to apache, i.e. apache: 2000, however
i got these from my console:
::: Case 4 ::: 2000
I want to get this value here: 0
what should i do to parse the integer? here below is some of my codes.......my java file can be compiled without problem but just wanna get that apache: 2000 but not 0......thanks experts!
//Added 20061017
private static final String PKEY_BATCH_SIZE = "interface.batch.size";
Integer apache = new Integer(0);
//Added 20061017
private ArrayList pConfigs = new ArrayList();
private String pSchema;
private String pLogger;
private String pDatePattern;
// private String pSeqPath;
private static HashMap pConnectionMap = new HashMap();
private static HashMap pSeqMap = new HashMap();
public static void main(String[] args) {
Properties prop = new Properties();
try {
//added (start)
//
int xyz_here = 0;
if (prop == null) {
xyz_here = 1000;
System.out.println("::: Case 1 ::: " + xyz_here);
}
if (Integer.valueOf(prop.getP
xyz_here = 1000;
System.out.println("::: Case 2 ::: " + xyz_here);
}
if (Integer.valueOf(prop.getP
xyz_here = 1000;
System.out.println("::: Case 3 ::: " + xyz_here);
}
if (Integer.valueOf(prop.getP
//xyz_here = 1000;
xyz_here = Integer.valueOf(prop.getPr
System.out.println("::: Case 4 ::: " + xyz_here);
}
Integer apache = new Integer(xyz_here);
//added (end)
}
}
public void start(InterfaceConfig config) {
System.out.println("I want to get this value here: " + apache);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the error shows non-static variable apache cannot be referenced from a static context
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it works now! thank you for your help, experts
ASKER
my JDK there's something wrong with this row