Calling a variable by 2 names

Some times I want to call a variable by an indexed name.
for (int i= 0; i <5; i++)
array[i] = from;
from[0] contains the number of names
from[1] contains the number o people
from[2] contains the number of dogs
from[3] contains the number of cats
from[4] contains the number of birds
In other parts of the program, to make it more understandable, I want to refer to numOfBirds rather than from[4]. countOfBirdies = numOfBirdsIs there a way to set up the name equivalence in Java?
Thank you                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

zscipio wrote:
I am interested is satisfying both concepts as it is possible in some other languages. One simple way is to introduce named indexes, like
public class NumberOf {
   private NumberOf(){} // private constructor to prevent instantiation
   public static final int NAMES = 0;
   public static final int PEOPLE = 1;
   public static final int DOGS = 2;
   public static final int CATS = 3;
   public static final int BIRDS = 4
   public static final int SIZE = 5; // number of constants
}Now you can do,
for (int i= 0; i <NumberOf.SIZE; i++) {
   array[i] = from;
countOfBirdies = array[NumberOf.BIRDS];It's probably not exactly what you wanted but at least you're using symbolic names rather than naked indexes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to print a request variable in the name of a section?

    Hello all,
    I have a session variable created in the RPD called VarWorstStore
    and I have a prompt which sets a request variable with the same name.
    Now when I put a report which is filtered on this variable then I can see that the variable is changing when I press go in the dashboard prompt.
    However, I call this variable in a section as well (go to page options - edit dashboard and click on rename of a section)
    Now I type: @{biServer.variables['NQ_SESSION.VarWorstStore']} and check the box Display section heading.
    Now when I save the dashboard I can see the value of the session variable. However, when I change the session variable with the prompt, thenb I can see that the report is changing, but the title isn't.
    Can anyone help me on this? My reference on this was: http://4.bp.blogspot.com/_f689sAiiG-E/SKv8Fxu7wNI/AAAAAAAAAPk/pppwQ1DdEhg/s1600-h/obi-ee-variables-overview.jpg
    I think it is a bug, but perhaps someone knows
    OBIEE version:
    Build: 10.1.3.4.1.090414.1900
    Release Version: Oracle Business Intelligence 10.1.3.4.1
    Package: 090414.1900

    Thanks for all your responds!!
    However, I was thinking in first instance on a narrative view myself indeed, however this is not good enough for me, because I really have an almost pixel perfect dashboard.
    But the thing with the prompt works!!! What I have done is making an extra prompt with the default value set to the session variable and then I set a presentation variable in the same prompt, and after that I am filtering the reports on the presentation variable in stead of the session variable.
    But I cannot find anywhere where to hide the prompt, can you tell me this?
    The only way I can hide things is to set permissions I gues, but then I also guess is that the prompt will do not do its tasks when the user has no permissions to this prompt.
    Hope you can help me out on this last part!!

  • Unknown variable or property name 'ReportFilePath'. Error accessing item 'Runstate.Root.Locals.ReportFilePath'. in TestStand

    Hi all.
    I was using Teststand 4.2 up to last week and upgraded to TS 2013. In 4.2 I was using the following to get the location of the teststand report:
    Runstate.Root.Locals.ReportFilePath
    but with TS 2013 this no longer works.. is the following error:
    Unknown variable or property name 'ReportFilePath'.
    Error accessing item 'Runstate.Root.Locals.ReportFilePath'. in TestStand - Get Property Value (String).vi->
    I've tried the following now with no success:
    RunState.Root.Report.Location
    So my question is how can I get the location (path) of the report file during test programmatically please?
    Please find enclosed a screenshot of the report config:
    Solved!
    Go to Solution.
    Attachments:
    TS_ReportConfig.png ‏42 KB

    Shashidhar,
    Thanks for your help! With your tips, I finally got it to work. For anyone else trying to modify report names based on user input after the sequential process model sets the file name path I will re tell what I did:
    Edit the Ni_RerportGenerator.seq plugin found in C:\Program Files (x86)\National Instruments\TestStand 2014\Components\Models\ModelPlugins\
    You go into this file and add the step higlighted in Blue at that same location. Please see the expression I typed in the expression box. Setting Parameters.ReportOptions.NewFileNameForEachUUTStatus to true forces re-evaluation of the report name at the end of the sequentialmodel.seq.
    Then you add a FileGlobal in the sequenatialmodel.seq. I called my FileGlobal ReportFileName
    Then I added an expression in my test sequence that modified the the new FileGlobal I created:
    Finally I updated the report options (Go to Cofigure>Report Options > Report File Pathname and under File/Directory Options select "Specify Report File Path by Expression" and I entered my expression. It appears that you can disregard the evaluated report file path error (box below) because your pathname won't be generated until run-time.
    This worked well for me hopefully it will for others. 
    Thanks,
    Marco

  • How to call a variable from another class?

    Greetings
    I�m designing a program that is called Senior.java, and I want to design it�s menus, for simplicity in reading the code, I want to write a separate java file for each menu. For example I want a file.java, edit.java etc�.
    Since I�m not a professional I�m having problems in calling the variable �bar�, that I created in senior.java,
    In Senior.java I have :
    JMenuBar bar = new JMenuBar();
    setJMenuBar( bar );
    In fileMenu.java I want to add file menu to the menu bar �bar�:
    bar.add( fileMenu );
    When I compile the fileMenu.java I got a �cannot resolve symbol � message, where symbol is the variable bar.
    Can you please help me, knowing that i'm using SDK1.4.1?

    Sun has recommendations for naming conventions. Class names should start with a capital letter. You should avoid using class names that are the same as classes provided in the SDK. Following these conventions will make it easier for people to help you. For example, you should not use file, nor should you use File. It's better to use MyFile, replacing My with something that makes sense to your application (SeniorFile?).
    Also, check the Formatting Help link when posting for a desciption on how to use the code tags for posting code.
    1. You need to establish references between your classes. One way is to have a constructor that has a JMenuBar argument.
    2. You can not add a file to a JMenuBar because a JMenuBar adds a JMenu. I don't think you want file to extend JMenu. It may be better for file to have a JMenu.
    I haven't tried to compile this code so no guarantees - just trying to show you an approach.
    public class Senior extends JFrame {
       public Senior() {
          JMenuBar bar = new JMenuBar();
          MyFile file = new MyFile(bar);
    //whatever else you need
    public class MyFile {
       public MyFile(JMenuBar mbar) {
          JMenu menu = new JMenu();
          mbar.add(menu);

  • Calling instance variable...

    Hi,
    Just wondeirng if I defined some instance variables in a class. If I want to call the variables in another class. Is it like <class_of_variables_are_defined>.<variables> ?

    Here are the codes I have written...I am still having a little trouble though
    Variables that I have defined in two different class...
    Ride.class
    public class Ride
         private String name;
         private int ticketsRequired, numberOfRiders;
         private float heightRequirement;
         public String getName()
              return name;
         public int getTicketsRequired()
              return ticketsRequired;
         public int getNumberOfRiders()
              return numberOfRiders;
         public float getHeightRequirement()
              return heightRequirement;
    TicketBooth.class
    public class TicketBooth
         private float moneyMade;
         private int availablePasses;
         public float TICKET_PRICE = 0.5f;
         public float PASS_PRICE = 16.5f;
         public float getMoneyMade()
              return moneyMade;
         public int getAvailablePasses()
              return availablePasses;
         public TicketBooth(int initAvailablePasses)
              availablePasses = initAvailablePasses;
                         .....Now when I try to use those private instance variables in Person.class, I got bunch of errors. I know private instances can only be used within the class they defined. How should I correct the code below?
    Person.class
                         public boolean buyPass(TicketBooth booth)
              if (hasPass == true && money >=  PASS_PRICE)
                   return true;
              else
                   return false;
         public boolean allowedToRide(Ride aRide)
              if (height >= heightRequirement &&
                 (hasPass == true || ticketCount >= ticketRequired))
                   return true;
              else
                   return false;
         public void getOn(Ride aRide)
              if ((allowedToRide(aRide) == true) && (hasPass == true))
                   availablePasses -= 1;
                   numberOfRiders += 1;
              else if(ticketCount >= ticketRequired)
                   numberOfRiders += 1;
                   ticketCount -= ticketsRequired;
                         .......

  • Calling a variable from main class to other class

    How do I call a variable that is initialize in the Test.java into Sub.java?
    I want to call the a, b, c that I have initialize in Test.java into Sub.java.
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    public class Test{
         public static void main(String args[]){
              int b;
              int c=1;
              int a=11;
              b = c + a;
              System.out.println(+b);
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    public class Sub{
         public void Subtraction(){
              if(a>c)
                   b = a-c;
              else if(c>a)
                   b = c-a;
              else if(a=c)
                   b = a-c;
              System.out.println(+b);
    }

    This is, and I'm sorry but I don't know how else to say this, a real big mess.
    I'll go through some (most/all) of it but honestly....
    import java.awt.*;Many will tell you that you should use specific imports and not wildcards to increase ease of reading. I am not so personally picky about this but it would help you.
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*; Don't import things you never use. It just adds confusion get rid of java.util import
    import java.lang.Object.*;Redundant. Remove it.
    import java.applet.Applet.*;Unused. get rid of it
    public class SUBOK {      Terrible class name. Please use the standard [_Java naming conventions_|http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html]
    public int a = 10;
        public static void main(String[] args) {
             SUBOK runGUI = new SUBOK();
        public SUBOK(){
             JFrame f = new JFrame("Subok");
             f.setSize(150,100);
             f.setVisible(true);
             f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
             JButton b = new JButton("Sum");
             b.setActionCommand("send");
             b.addActionListener(new Push());
             JPanel p = new JPanel();
             p.add(b);
             f.add(p);
        } Most of that is okay although not great. But I don't think you should be doing anything in Swing at all yet.
      private class Push implements ActionListener{
             public void actionPerformed(ActionEvent e){
                  if(e.getActionCommand().equals("send")){
                       int a = 12;You are aware that this a has nothing to do with your other a? right? I mean this is a method local variable in a whole other class then the other one.
                           Add i = new Add();
                           i.Add();                
        public int aValue(){
             return a;
    } Alrighty then...
    import java.lang.*;Redundant. Remove You never need to import java.lang.
    import java.awt.*;Unused. remove.
    import java.util.*;Unused remove.
    public class Add {
         SUBOK a = new SUBOK();
         int d = a.aValue(); Aiaiaiai.
      public void Add() {
             int b;
             int c = 0;
             b = d+c;
             System.out.println(b);
    }First of all do not name a method the same as a class. Second most of this class appears to be based mainly in the realm of wishful thinking. In programming, wishing that something will "just work" without understanding the basics of why and how it works does, pretty much 100% of the time, not end well.
    You need to take a number of steps back from this code, get grounded in some fundamentals and then make another attempt. I would highly recommend putting the Swing (or any other GUI) code aside for some time now. Inter-object communication is a fundamental part of OO and thus a fundamental part of Java and this code clearly shows that you don't understand it yet at all.
    Start here [_Learning The Java Language_|http://java.sun.com/docs/books/tutorial/java/index.html]
    If you have questions as you go through the tutorial do come back and ask them and someone here will be glad to help you. But in order to help you with code you have to be at a point where you understand things like variable scope, the difference between a class and an Object and how, why and what methods can be used to exchange information between two instances.

  • Undefined variable or class name

    I am trying to call a java class to another class but gets the error: "Undefined variable or class name"
    Both my java files are in the same directory and I am able to compile only one of the program. Wondering what am I missing?
    The source code is:
    ServletUtilities.java: (I am able to compile)
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ServletUtilities {
    public static final String DOCTYPE =
         "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
         "Transitional//EN\">";
    public static String headWithTitle(String title) {
         return(DOCTYPE + "\n" +
              "<HTML>\n" +
              "<head><title>" + title + "</title></head>\n");
    HelloWWW3.java (getting error when compile)
    public class HelloWWW3 extends HttpServlet {
    public void doGet(HttpServletRequest request,
                   HttpServletResponse response)
         throws ServletException, IOException
         response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println(ServletUtilities.headWithTitle("Hello WWW") +
              "<body>\n" +
              "<h1>Hello WWW</h1>\n" +
              "</body></html>");

    I tried and I got these errors:
    C:\java servlets\HelloWWW3\src>javac -classpath . HelloWWW3.java
    HelloWWW3.java:4: Package javax.servlet not found in import.
    import javax.servlet.*;
    ^
    HelloWWW3.java:5: Package javax.servlet.http not found in import.
    import javax.servlet.http.*;
    ^
    HelloWWW3.java:7: Superclass coreservlets.HttpServlet of class coreservlets.Hell
    oWWW3 not found.
    public class HelloWWW3 extends HttpServlet
    ^
    3 errors
    Then I moved HelloWWW3.java and ServletUtilities.class file to C:\jakarta-tomcat-3.2.3\lib
    This dir has files
    JAXP JAR
    SERVLET JAR
    ANT JAR
    PARSER JAR
    WEBSER~1 JAR
    JASPER JAR
    and compiled and got this error
    C:\jakarta-tomcat-3.2.3\lib>javac -classpath . HelloWWW3.java
    HelloWWW3.java:4: Package javax.servlet not found in import.
    import javax.servlet.*;
    ^
    HelloWWW3.java:5: Package javax.servlet.http not found in import.
    import javax.servlet.http.*;
    ^
    HelloWWW3.java:7: Superclass coreservlets.HttpServlet of class coreservlets.Hell
    oWWW3 not found.
    public class HelloWWW3 extends HttpServlet
    ^
    3 errors
    Here is what I hava defined for my CLASSPATH
    C:\jakarta-tomcat-3.2.3\lib>echo %CLASSPATH%
    C:\jakarta-tomcat-3.2.3\lib\servlet.jar;C:\jakarta-tomcat-3.2.3\lib\jasper.jar
    ------------------------------------------

  • [HELP] Error, Unknown variable or property name '', error. No Details???

    Our production team ran some of our TestStand software when it froze.  Upon exiting the report file contained only one error:
    “Error, Unknown variable or property name ''. [Error Code: -17306, Unknown variable or property name.]”
    This has not happened before with this test sequence.
    Now I have seen this before, during development of other TestStand projects, but there are usually details of the unknown variable in the error.  This one just has empty quotes!  There are around twenty sequences called in this software.  Is this a rouge error, a symptom of the freeze, or do we have an unknown variable issue in these sequences?
    Christopher Povey
    Senior Test Systems Engineer for BAE Systems.

    Hi Christopher,
    As you say as part of the Error Message you should of had the Variable name.
    With this freeze and if you had to force exit of the TestStand, it would seem that to get any report at all you must be doing some sort of 'On the Fly' reporting. If so, can you pin point what the test sequence was doing to try to identify the cause of the freeze.
    Maybe you are obtaining the variable name dynamically and because of the crash this value was not obtained and therefore you were passing an empty string. Hence no variable name in error message.
    Regards
    Ray Farmer

  • Why does DB_PLImpotExportProperties throw "Unknown variable or property name. (Error = -17306)"?

    When I run GenericImportExport.seq, the call to  DB_PLImpotExportProperties brings up the Import/Export dialog. When I copy that step into my existing sequence, the error "Unknown variable or property name. (Error = -17306)" is thrown. I can see no difference between the two. They also appear to be running in the same environment.
    Any suggestions?
    Solved!
    Go to Solution.

    So this was bothering me enough that I went back and recreated the problem. I cannot even call the entire sequence without getting this error.
    I added a step to my test sequence that makes a call to the sequence GenericImportExport.seq in a separate file (where it was installed). Right-clicking on the the step and selecting "Run Selected Steps" causes the subject error.
    I CAN use the tool menu "Import/Export properties..." or open the sequence itself and run ImportExport without a problem.

  • How can I call a variable from another class

    hi
    If I have two classes : one and two
    In class two I have a variable called : action
    In class one I want to check what is the value of action.
    How can I call action?

    Thank you scorbett
    what you told me worked fine, but my problem is that MyClass2 is an application by itself that I don't want to be executed.
    Creating myClass2 as in the following:
    MyClass2 myClass2 = new MyClass2();
    [/code]
    executes myClass2.
    Can I prevent the exectuion of MyClass2, or is there another way to call the variable (action)?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I found out that I have some lost contacts on my iphone 5s, they dont appear when I search but if the contact calls me I see their name. How can I get those contacts to be on the list?

    I found out that I have some lost contacts on my iphone 5s, they dont appear when I search but if the contact calls me I see their name. How can I get those contacts to be on the list?

    You could check settings > mail contacts and calandars and see if there are any accounts (like icloud gmail yahoo) listed and if they have contacts on. Its possible if contacts were synced to one of these accounts that turning them back on will recover the missing contacts.

  • How do I remove my caller id from my samsung convoy phone so that the person I call does not see my name?

    How do I remove my caller id from my samsung convoy phone so that the person I call does not see my name?

    MojaveMoon's solution will work if there is only one person you want to block your ID from; if you want to block your caller ID from everyone, you can go to your account online, go to Change Features, and scroll down till you see Caller ID block.  Instructions say that once this is activated, you can dial *82 before any # you WANT to display your number to, but all others will be blocked.
    If you are on a Family share plan, the account owner needs to log in and choose your line to activate this feature.

  • How to run the variable exit without calling the variable selection screen?

    Hi all
    I have a query with 2 variables 0P_PRQUA (Previous Calendar Quarter (SAP Exit)) and ZCCDAT02.
    ZCCDAT02 is a Key Date variable that is derived based on the last day of the quarter that is entered in 0P_PRQUA. The exit code works correctly when calling up the variable screen and ZCCDAT02 is derived properly.
    The problem is that 0P_PRQUA is set to "Can be changed in query navigation". So if the user changes the value of the quarter the exit is not triggered and the value of ZCCDAT02 does not change.
    Is it possible to trigger the exit or is there another way to do it? Ideas would be appreciated. I am trying to create a Web Template with a Dropbox box for the Quarter.
    Query is written in BW 3.X.
    Regards
    Chami

    Hi guys
    Just to restate the requirement. I want the user to be able to change the value of the variable, WITHOUT calling the variable selection screen.
    I want the user to be able to change the value of the quarter by using a dropdown box from within the web template. Once that is selected I want the value of ZCCDAT02 to be derived from the new value of the quarter.
    Regards
    Chami

  • Fix variable text (File Name) when importing INDD into INDD

    More of a fix request than a new feature:
    Simply put, the variable text (File Name) shows the file extension when the document is imported into another INDD regardless of the variable text specifications in the originating document. This is unexpected and undesired.
    Please see problem description in this thread: http://forums.adobe.com/thread/489492?tstart=0

    Seconded. Currently, I don't use this variable in this way, but I can envisage future scenarios where it would be a problem.
    And it seems a strange thing to miss out on ... (why would an INDD file behave different?)

  • On my new iPad Siri calls me my wife's name

    Why does Siri call me my wife's name?

    Hi
    Refer to the post I made regarding Wifi does not work
    In setting select your wifi connection and enter the connected network
    Scroll down to HTTP proxy and select Auto
    That solved my wifi issue
    Cheers

Maybe you are looking for

  • Can't install iTunes9 on windows 7

    Got new iPod nano for xmas and now i can't download iTunes to use it! I tried every possible solution offered on the support sites and nothing is working.... when i start the download it will freeze and random stages of the process.....some times 29%

  • How to buy ebooks with adobe?

    How to buy ebooks from adobe

  • How can I access my Apple account

    I cannot receive my e-mail to verify my itunes account.

  • Echinus Start-up applications

    I recently gave the echinus a try. Itis amazing. Fully Extended Hint Compliant. But there is a minor issue. I want to start a couple of command when echinus starts and I want it to be echinus specific (i.e I can't use places and methods that are bein

  • RCU error

    Hey, trying to run Repository Creation Utililty, but got the following error as soon as i start to run ./rcu. SO: Enterprise Linux 2.6.18-8.el5 any ideas? Thanks, Pedro Ribeiro [oracle@oel5-vm bin]$ ./rcu Exception in thread "AWT-EventQueue-0" java.l