Click here to Skip to main content
15,917,566 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do i actually use the String first_ param value and print out at outside the if/else ?

What I have tried:

Java
String sjcb_EM = jcb_EM.getSelectedItem().toString();
        
        if (sjcb_EM == "Evey Minute"){
            
            String first_param = "*";
        }

        System.out.println(first_param);
Posted
Updated 12-Jan-18 9:36am

You need to DECLARE first_param outside the if { ... } block, and SET it inside.

String sjcb_EM = jcb_EM.getSelectedItem().toString();

        String first_param = "";
        
        if (sjcb_EM == "Evey Minute"){
            
            first_param = "*";
        }
 
        System.out.println(first_param);
 
Share this answer
 
v2
Declare it outside of the if statement. If you don't declare it outside of it, it will only be declared inside of the if statement and won't be able to be called on.
 
Share this answer
 
Comments
Patrice T 12-Jan-18 15:39pm    
This is only a rephrasing of solution1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900