Would like to declare a variable Public/Global in an IF statement

Is there way to declare a variable as Public in an IF statement. My goal is to declare the variable as global (since this variable is used somewhere in the code and should not get initialized when there is loop back to the top of the code, hence using IF statement to control the initialization) based on the IF condition and then use it elsewhere in the code.
I have it like this
if (!sei_second_jsp.equals("1"))
public int[] mecitem;
public String[] sei_mfg_prod_cat;
public String[] sei_part_number;
public String[] sei_descrip;
public String[] sei_price;
public int[] sei_onhand;
public int[] sei_demand;
mecitem = new int[20000];
sei_mfg_prod_cat = new String[20000];
sei_part_number = new String[20000];
sei_descrip = new String[20000];
sei_price = new String[20000];
sei_onhand = new int[20000];
sei_demand = new int[20000];
for (int i=0; i<=19999; i++)
mecitem[i] = 0;
sei_mfg_prod_cat[i] = " ";
sei_part_number[i] = " ";
sei_descrip[i] = " ";
sei_price[i] = " ";
sei_onhand[i] = 0;
sei_demand[i] = 0;
Your guess is right, I am using this code in JSP - since this is a Java related question, thought of posting it in JAVA forum.
When I use the above code, I get the following error
1809 }' expected. { 
1811 Statement expected. public int[] mecitem;
1827 Identifier expected. mecitem = new int[20000];
1827 Can't specify array dimension in a declaration. mecitem = new int[20000];
1827 Identifier expected. mecitem = new int[20000];
1837 Can't specify array dimension in a declaration. sei_onhand = new int[20000];
1837 Identifier expected. sei_onhand = new int[20000];
1839 Can't specify array dimension in a declaration. sei_demand = new int[20000];
1839 Identifier expected. sei_demand = new int[20000];
3117 Class or interface declaration expected. }

Please note the above code in the JSP is submitting to itself and I donot want it to get initialized if the IF statement is not successful..
thnks a lot for your time.. !!!

Similar Messages

  • Is there any reason (laziness aside) to declare instance variables public?

    Why would you declare one public, save for the fact that object.field is quicker to type than object.getField()? It is a pain to have to write get/set methods for private variables, but later on, if you ever need to do something with a variable when it's been accessed or modified, it's much easier to go back and edit just those methods, instead of everywhere the variable's been directly accessed. On the other hand, I see no benefit of declaring a variable public. Is there one?

    Never, Never, Never !!!That's a tad extreme.
    In most cases, you'll want get and set, and even then you need to examine whether you really want another class to have that direct control over your object's state.
    But there are cases where you can make your instance variables public. If it's a pure data container, with no behavior, and you don't expect it to ever be used in a multithreaded context or to be used as a JavaBean, then you can make the instance variables public.

  • Which topics you would like to see featured on Public Sector BPx content?

    Dear community,
    We would like to hear from you...
    - On which topics would you be interested to get/share further information?
    - What would be a good Blog to organize?
    - Should we open a thread in the forum to discuss about a particular topic?
    - Would you like to share some documents within the BPx library?
    best regards,
    The Public Sector Community

    We are currently planning an upgrade to the ERP 2005s release that will include the new Tax and Revenue Management features. We have been using SAP FI-CA and SD for out tax processing for years and really look forward to finally getting a tax processing solution out of the box from SAP.
    Thanks

  • Public/Global variable within an If statement..

    Is there way to declare a variable as Public in an IF statement. My goal is to declare the variable as global (since this variable is used somewhere in the code and should not get initialized when there is loop back to the top of the code, hence using IF statement to control the initialization) based on the IF condition and then use it elsewhere in the code.
    I have it like this
    if (!sei_second_jsp.equals("1"))
    public int[] mecitem;
    public String[] sei_mfg_prod_cat;
    public String[] sei_part_number;
    public String[] sei_descrip;
    public String[] sei_price;
    public int[] sei_onhand;
    public int[] sei_demand;
    mecitem = new int[20000];
    sei_mfg_prod_cat = new String[20000];
    sei_part_number = new String[20000];
    sei_descrip = new String[20000];
    sei_price = new String[20000];
    sei_onhand = new int[20000];
    sei_demand = new int[20000];
    for (int i=0; i<=19999; i++)
    mecitem[i] = 0;
    sei_mfg_prod_cat[i] = " ";
    sei_part_number[i] = " ";
    sei_descrip[i] = " ";
    sei_price[i] = " ";
    sei_onhand[i] = 0;
    sei_demand[i] = 0;
    Your guess is right, I am using this code in JSP - since this is a Java related question, thought of posting it in JAVA forum.
    When I use the above code, I get the following error
    1809 }' expected. { 
    1811 Statement expected. public int[] mecitem;
    1827 Identifier expected. mecitem = new int[20000];
    1827 Can't specify array dimension in a declaration. mecitem = new int[20000];
    1827 Identifier expected. mecitem = new int[20000];
    1837 Can't specify array dimension in a declaration. sei_onhand = new int[20000];
    1837 Identifier expected. sei_onhand = new int[20000];
    1839 Can't specify array dimension in a declaration. sei_demand = new int[20000];
    1839 Identifier expected. sei_demand = new int[20000];
    3117 Class or interface declaration expected. }
    I will post the same in JSP forum as well.. thnks a lot

    1809 }' expected. { I would guess that you have a syntax error above this error. The other errors are caused by that.

  • I would like have a graphic object appear (visible) and disappear based on future slide

    I would like to know if it is possible to make a graphic or button appear (make visible) and disappear on a slide after the completing furure slides that return to that particular slide.  Basically, the initial slide has several buttons that go through several videos and questions. At the end of each series of slides, I return to initial slide and that is where I'd like to place a completion graphic. Is there anyway the visible field can be updated for a graphic or button?

    Welcome to our community
    Absolutely that's possible to achieve. You would use Variables and Advanced Actions to do it.
    Basically you would need to declare a variable to track whether the slide has been visited or not. Then use the Advanced Action to reveal (or hide) the image based on teh value of the variable.
    Cheers... Rick
    Helpful and Handy Links
    Begin learning Captivate 5 moments from now! $29.95
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcererStone Blog
    Captivate eBooks

  • I would like to display current fiscal year always on variable screen

    Hi
    I have requirement in which I would like to display the current fiscal year on variable screen in BI Report.
    we have a standard variable however the sap exit to display the current fiscal year is not shown...
    Can any one tell me, how to proceed in this case.
    Thanks
    Chetan

    Hello,
    For I-step = 1, use the function module DATE_TO_PERIOD_CONVERT.
    here for IMPORT use i_date = sy-datum and i_periv = ur fiscal variant.
    The output is e_buper contains fiscal period and e_gjhar contains fiscal year.
    The use concatenate to join fiscal year and fiscal period to the variable low value.
    Regards,
    Shashank

  • I am a teacher of IT Information Technology for high school students of a public school in the state of Minas My Brazil, and would like to know if you guys have dreamweaver cs5 for students and flash, so I can teach students the construction of these site

    I am a teacher of IT Information Technology for high school students of a public school in the state of Minas My Brazil, and would like to know if you guys have dreamweaver cs5 for students and flash, so I can teach students the construction of these sites trough applications

    Hi,
    In addition to what Ken said, I would suggest that you give Edge Animate a shot as well.
    Creative Cloud is available as trial version for 30 days and almost all creative software is bundled with the Creative Cloud. Tutorials are included for each of the products on the respective sections of the website. For instance, this site Website builder | Download free Adobe Dreamweaver CC trial gives you access to the trial version as well as tutorials.
    I suggest that you go to http://creative.adobe.com and explore the various options available.
    For any purchase related information, feel free to send me a private message if you need further clarification. Click on my picture and use the message option. The experts on this forum can help you with other questions you have on using Creative Cloud.
    Thanks,
    Preran

  • I would like to send a movie to a select few without having it open to the public. How do I do that?

    I made a movie that I would like to send to friends and family but not have it available to the public.
    Since Mobileme doesn't exist anymore, how do I do that? Thanks

    That would be a YouTube question not an iMovie question.
    Also this is the forum for iOS (iPads and iPhones).
    I can give you one solution though.
    Publish to You Tube and choose the "unlisted" option.
    This way it can only be videwed by people who have the link.
    You get given the link once it is published.

  • Would like Table Continuation Variable added to a paragraph style, such as to a table title

    My groups uses both Frame 7.2 and Frame 9 and we would like to include the Table Continuation variable to our table title paragraph tag definition so that we don't have to manually add the variable. Is this possible now? If so, how?
    Thanks
    Sherri McCue
    Synopsys, Inc.

    Hi Sherri,
    I guess it is possible. I am attaching a screen shot you can follow that.
    this is for Framemaker 9 and I am not sure about framemaker 7.2
    I hope this helps you.,
    Thanks & Regards
    Priyank

  • I work in a public library and we have two ipod touch and two ipod nanos we would like to circulate for our patrons. Any advice on how we can do this? Should we allow patrons to set the device up for personal use or download static content?

    I work in a public library and we have two ipod touch and two ipod nanos we would like to circulate for our patrons. Any advice on how we can do this? Should we allow patrons to set the device up for personal use or download static content?

    With the Nanos, you should have no problem lending them loaded with audiobooks from Librivox, etc.
    As for the iPod Touches, I'm not sure the question is whether you should allow patrons to set up the device for personal accounts, but whether you can prevent them from doing so. Prepare to to a factory restore every time one is returned.

  • Would like to use @variable('BOUSER')

    Hi All,
    I am working with
    -->   Business Objects XI R2 (View Crystal Report using InfoView)
    -->   Business Views XI R2  ( access the data using Oracle 10g ) building LOV location table with the
           proper access to the location(s) they have  to.
    -->   Crystal Reports XI R2 (Database connection is the Business View)
    I need to pass the BO User ID of the person running the report to the Oracle db.
    Any suggestions would be greatly appreciated.
    ====================================================
    I am working with 2 tables
    -->   LOCATION_SECURITY.SECURITY_ALL_LOCATIONS
    -->   LOCATION_SECURITY.SECURITY_FOLDER_LOCATION
    If they exist in the LOCATION_SECURITY.SECURITY_ALL_LOCATIONS table then give them access to all locations also I want to display ...ALL value at the top of the LOV.
    If they exist in the LOCATION_SECURITY.SECURITY_FOLDER_LOCATION table then give them access to all only the locations they have access to I DO NOT want to display the  ...ALL value at the top of the LOV.
    Proposed Oracler View
    Select @variable('BOUSER'), 99999 as Folder, '...ALL' as Location, 'All Locatiions' as Description
    From dual
    where (select Q.User_ID from LOCATION_SECURITY.SECURITY_ALL_LOCATIONS
              where Q.User_ID = @variable('BOUSER')) Is not null
    UNION
    Select C.User_ID, 99999 as Folder, B.Location, B.LocationName
    From medgate_v60_app.MT_TBLLOCATION  B left join
         LOCATION_SECURITY.SECURITY_ALL_LOCATIONS C on C.User_ID Is not null and
         C.User_ID = @variable('BOUSER')
    UNION
    Select D.User_ID, D.Folder_ID, D.Location, E.LocationName
    from LOCATION_SECURITY.SECURITY_FOLDER_LOCATION D Left Join
           medgate_v60_app.MT_TBLLOCATION E on D.Location = E.location
    WHERE 
      D.Folder_ID in (SELECT O.REAL_FOLDER_ID FROM LOCATION_SECURITY.FOLDER_MAPPING O) 
      and @variable('BOUSER')

    Do you need to use an SSO authentication?
      NO I am using an Oracle UserID for everyone with no prompt for password
    Do you need to verify that you BOUSER matches a user stored in a table?
    YES  the user either belongs in either the SECURITY_ALL_LOCATIONS table or the SECURITY_FOLDER_LOCATION table
    Can you detail the workflow you want to do with BOUSER?
    I know that in Business Views I can use CurrentUserName in a filter to select the person I want by using I would like to pass to the Oracle SQL View the user running the BO USER running the report.:
    Here is what the original Oracle View looks like.
    Select A.User_ID, 99999 as Folder, '...ALL' as Location, 'All Locatiions' as Description
    From   LOCATION_SECURITY.SECURITY_ALL_LOCATIONS A
    UNION
    Select C.User_ID, 99999 as Folder, B.Location, B.LocationName
    From  medgate_v60_app.MT_TBLLOCATION  B left join
             LOCATION_SECURITY.SECURITY_ALL_LOCATIONS C on C.User_ID Is not null
    UNION
    Select D.User_ID, D.Folder_ID, D.Location, E.LocationName
    From LOCATION_SECURITY.SECURITY_FOLDER_LOCATION D
              Left Join medgate_v60_app.MT_TBLLOCATION E on D.Location = E.location
    Where D.Folder_ID in ( SELECT O.REAL_FOLDER_ID FROM LOCATION_SECURITY.FOLDER_MAPPING O )
    Edited by: Rick Phillips on Jan 29, 2009 3:56 PM

  • I would like to buy a developer license to use on a mac at a public library from a flash drive any issue with this?

    I would like to buy a developer license to use on a mac at a public library from a flash drive any issue with this? Very new to this

    The license is for the Developer not the machine it is run on However there could be soma issues with trying to develop on a public machine.
    The biggest is does the library machine have or will they let you install  and run Xcode and if you are developing for IOS will they let you plug in your devices?
    In addition will they allow you the hours needed on the machine? Most public machines have a time limit especially if there are others waiting to use it.
    All-in-all in can be done but it won;t be an easy situation.
    good luck

  • Making variable values globally accessible in my code

    I have certain variables, and when I declare their values
    within a function I want the value to be accessible in other
    functions. Right now it's not, so obviously I have a scoping
    problem.
    For this example, I have a function that decides if an avatar
    is too close to the side of the screen, in which case it sets a
    flag var tooClose:Boolean = true; Of course my other functions
    don't see this and aren't getting the message.
    In old 2.0 I would have just said _root.tooClose = true or I
    would have made the variable global.
    Could someone please help me here? Its something I find
    myself needing quite a bit.

    Let me be clearer:
    var myFlag:Boolean = false;
    function resetVariable() {
    var myFlag = true
    function checkVariableValue() {
    trace(myFlag)
    // shows false
    I would like it so when I set the variable myFlag = true in
    the resetVariable function that the global value for myFlag becomes
    "true" and all my other functions are aware of it.

  • Persisting variables to global scope (M spec's 'shared' keyword?)

    Hi,
    I wanted to declare multiple variables I'd like to reuse in a query, and be able to keep them in scope afterwards for use in other queries. The alternative of redeclaring them in each query separately would seem tedious, while individual queries can also
    only return one variable each (be it a table/list).
    I read in the M formula specification that it should be possible to global-scope a variable using the 'shared' keyword, though apparently this was only for use in the 'sections' part of the M specification unimplemented in Power Query itself. Am I missing
    something? Might there be some other way to persist a variable to the shared (global) scope from within a query?

    Thank you for the further clarification on sections; I didn't really know they are still kind of there in the background.
    Reconsidering, I suppose my perceived issue isn't really so bad. I think what I wanted (using M functions from text files like an external library) is pretty well doable, so I've Github'd (https://github.com/tycho01/pquery) what I have for others to try;
    perhaps that may help illustrate my use case a bit. I think I'm actually satisfied now, though I may as well explain better what I was trying.
    What I'm imagining (as an analogy to my experience with Excel VBA) is basically having a larger library of user defined M functions to flesh out the built-in ones, with smaller functions for relatively basic tasks, and mid-level functions building upon those
    and upon each other.
    Considering the (current) effort in adding a bunch of functions to different workbooks, not to mention edit syncing concerns, keeping such all-purpose functions separate from individual workbooks (in analogy to VBA's 'personal' workbook) would seem sensible.
    If that were to work out, eventually it may be preferable if things were to 'just work', in terms of all functions being in scope, so each such library function could freely call other such library functions.
    At present, if you load multiple functions through Expression.Evaluate(), possible in batch through lists/records as you mentioned, they will all be available in the original scope.
    However, with no effective way to pass this around (unless environments?), the loaded functions will not know of each other though. What I do now is to explicitly load used library functions in each function where they are needed. Under this limitation of losing
    scope between functions, it might be ideal to have all available functions loaded only once.
    Reloading in batch (i.e. load the whole library rather than the parts needed) within every new function scope may become less desirable in terms of unnecessary overhead.
    I suppose for the most part my scenario is still largely hypothetical though, so I might as well try and see if the general idea would take off in the PQ community for now. In either case, thank you for your replies.

  • Declare a variable in an Interface

    hi all
    can i declare a variable in a interface , something like
    public static final String dsn=" // something";
    so that i dont have to declare the same thing in all the classes that implement this interface
    regards

    You don't need the public, static, or final. All fields in interfaces are implictly public static final fields.

Maybe you are looking for

  • Acrobat 7 PDF forms question

    I have made my own form using acrobat 7  (my operating system is vista.)  It is a complex reporting system about 44 pages long. There are 15 or so text fields on the bottom of some pages for comments. I would like to auto fill into a summary all of m

  • Please help me find my audiobook

    I recently purchased a new ipad 2 and was surprised to find that Steve Jobs felt that Apple devices shouldn't require a manual.  Anyway last week I attempted to download an audiobook and aparently the download was interrupted.  The ipad I have is wif

  • Microsoft Office 2008 Powerpoint "cannot open the file because it has been moved or deleted"

    I am trying to open some slides my professor posted on Desire 2 Learn. It is a .pptx file. Everytime I try to open it I get an error message that says, "Powerpoint cannot access +I (drive) beacuse the file has been moved or deleted" I have uninstalle

  • Android Expansion Files and License Verification Library

    Hi all, I'm strugling with the libraries to verify a person's purchase in order to download play store hosted expansion files. I got the downloading of expansionfiles and unpacking (from an own domain) down, but since it is for a purchased applicatio

  • PP CC MASSIVE ISSUES!

    I am having some massive issues in PP CC... While importing clips through the media browser it crashes.. While linking media in the Link Media window, it crashes, 8 times out of 10.. While Warp stabilizing, it crashes. I have updated all drivers and