Link to home
Start Free TrialLog in
Avatar of manfredino
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.getProperty(PKEY_BATCH_SIZE).trim()).intValue() == 0) {
                xyz_here = 1000;
                System.out.println("::: Case 2 :::       " + xyz_here);
            }
            if (Integer.valueOf(prop.getProperty(PKEY_BATCH_SIZE).trim()).intValue() <= 1000) {
                xyz_here = 1000;
                System.out.println("::: Case 3 :::       " + xyz_here);
            }
            if (Integer.valueOf(prop.getProperty(PKEY_BATCH_SIZE).trim()).intValue() > 1000) {
                //xyz_here = 1000;
                xyz_here = Integer.valueOf(prop.getProperty(PKEY_BATCH_SIZE).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);

    }
ASKER CERTIFIED SOLUTION
Avatar of InteractiveMind
InteractiveMind
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of manfredino
manfredino

ASKER

i tried to replace it as apache = new Integer(xyz_here); but can't compile it......
my JDK there's something wrong with this row
the error shows non-static variable apache cannot be referenced from a static context
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it works now! thank you for your help, experts