How can i apply this in java ?

hi
I am looking to develop a program that recieving objects information and store them . i just tried initializing an array but it doesnt fit with our case because you have to give a limit for the array when you initialize it and our case is to receive unknown number of objects .
For example , store online which needs to store items and display it and delete the sold ones

use a Collection, such as ArrayList

Similar Messages

  • How can i  apply this  java program for  a jsp page?

    import java.io.*;
    import java.util.*;
    public class FileProcessing
      //create a vector container  for the input variables
         Vector variables = new Vector();
      //create a vector container for the constants
         Vector constants = new Vector();
      /*create a string expression container for the equation
         as read from the file */
         String expression = " ";
      //create double result container for the final result
         double result = 0;
         public boolean processFile(String filename,String delim)
          //index for values vector
              int num_values = 0;
          //index for constants vector
              int num_constants = 0;
          //current line being read from the external file.
              String curline = " ";
          //start reading from the external file
              try
                   FileReader fr = new FileReader(filename);
                   BufferedReader br = new BufferedReader(fr);
                   while(true)
                        curline = br.readLine();
                        if(curline == null)
                             break;
                    //determine the type of current interaction
                        boolean variable = curline.startsWith("input");
                        boolean constant = curline.startsWith("constant");
                        boolean equation = curline.startsWith("equation");
                        boolean output = curline.startsWith("result");
                   //on input variables
                        if(variable)
                          StringTokenizer st = new StringTokenizer(curline,delim);
                          int num = st.countTokens();
                          int count=0;
                          while(st.hasMoreTokens())
                               String temp = st.nextToken();
                               if(count==1)
                                    byte b[]= new byte[100];
                                    System.out.println(temp);
                                    System.in.read(b);
                                    String inputval = (new String(b)).trim();
                                    variables.add(num_values,inputval);
                                    num_values++;
                               count++;
                        // on constant values
                        if(constant)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==1)
                                       byte b[]= new byte[100];
                                       System.out.println(temp);
                                       System.in.read(b);
                                       String cons = (new String(b)).trim();
                                       constants.add(num_constants,cons);
                                       num_constants++;
                                  count++;
                        // on equation
                        if(equation)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==2)
                                       this.expression = temp;
                                  count++;
              // now we are ready to evaluate the expression
                       if(output)
                          org.nfunk.jep.JEP  myparser= new org.nfunk.jep.JEP();
                          myparser.setAllowAssignment(true);
                          for(int i=1;i<variables.size()+1;i++)
                             String name = "arg"+Integer.toString(i);
                             myparser.addVariable(name,new Double(variables.get(i-1)
                                                .toString()).doubleValue());
                          for(int i=1;i<constants.size()+1;i++)
                               String name = "arg" +Integer.
                                         toString(i+variables.size());
                               myparser.addConstant(name,new Double(constants.get(i-1).toString()));
                   //output is obtained as follows
                          myparser.parseExpression(expression);
                          result = myparser.getValue();
                          System.out.println("Assay value: "+result);
              catch(Exception e)
                   System.out.println(e.toString());
              return true;
         public static void main(String[] args)
              FileProcessing fp = new FileProcessing();
              fp.processFile("input.eqn",":");
    }//my text file name is: "input.eqn" (given below)
    input:Enter Value1:arg1
    input:Enter Value2:arg2
    input:Enter Value3:arg3
    constant:arg4
    constant:arg5
    Equation:arg1+arg2+arg3
    result:

    how can i apply this java program for a jsp pagewhy do you want to do this ?
    Your program reads from a file on the disk and formats based on a patterm.
    Jsp is not intended for such stuff.
    ram.

  • How can I uninstall this latest java upgrade?

    I just installed a java upgrade called "build 1.6.0_05-b13 and now I cannot get Microsoft Front Page 2003 to work. I have to use MS Front Page to maintain my website. How can I uninstall this latest java upgrade so it will go back to using my previous version of java?

    I believe you may have posted your question to the wrong forum. This forum is for the JavaHelp system, which is used for developing online Help for applications, not for general help on Java.

  • How can i apply this glowing effect in logo with illustrator?

    How can i apply this glowing effect in logo | ThemeForest Community Forums

    I would make several copies of the original artwork.  On each copy, section the individual areas to be gradients. It looks like you have at least four gradients, both linear and radial.  It's just a matter of building each section and then reassembling each.  Not too complex, yet nice piece of artwork.

  • How can i rewrite this code into java?

    How can i rewrite this code into a java that has a return value?
    this code is written in vb6
    Private Function IsOdd(pintNumberIn) As Boolean
        If (pintNumberIn Mod 2) = 0 Then
            IsOdd = False
        Else
            IsOdd = True
        End If
    End Function   
    Private Sub cmdTryIt_Click()
              Dim intNumIn  As Integer
              Dim blnNumIsOdd     As Boolean
              intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
              blnNumIsOdd = IsOdd(intNumIn)
              If blnNumIsOdd Then
           Print "The number that you entered is odd."
        Else
           Print "The number that you entered is not odd."
        End If
    End Sub

    873221 wrote:
    I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
    I'm just trying to get you to think about what your post actually says, and what others will take from it.
    what does this error mean? what code should i replace and add? thanks for all response
    C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=true;
    ^
    C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=false;
    ^
    2 errors
    Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
    It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
    So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself?

  • I just brought a brand new Macbook pro retina display, when i connect it to my apple tv through airplay its too slow and when it try to play a movie apply tv is always a minute or 2 behind. How can i fix this?

    I just brought a brand new Macbook pro retina display, when i connect it to my apple tv through airplay its too slow and when it try to play a movie apply tv is always a minute or 2 behind. How can i fix this?

    Hello HanaAmer1,
    We've an article which provides troubleshooting steps that can help get AirPlay workign correctly.
    iTunes: Troubleshooting AirPlay and AirPlay Mirroring
    http://support.apple.com/kb/TS5209
    Cheers,
    Allen

  • We have a requirement to print the w2 forms for employees using java application, how can i implement this. Please give some suggestion.

    We have a requirement to print the w2 forms for employees using java application, how can i implement this. Please give some suggestion.

    Anyone any ideas to help please?

  • Korean songs got cracked or broken on iTunes! How can I fix this? Can apple just offer a universal language applied to iTunes?

    Korean songs got cracked or broken on iTunes! How can I fix this? Can apple just offer a universal language applied to iTunes?
    English songs have right names but some Korean songs names got cracked .
    I set English as the first language on my Mac and don't want to set up language in English.
    Thanks.

    Assuming you are in a region where you are allowed to redownload your past music purchases, delete the broken tracks from your iTunes library, go to the iTunes Store home page, click the Purchased link from the Quick Links section in the right-hand column, then select Music and Not on this computer. You should find download links for your tracks there.
    If the problem persists, or that facility is not yet available in your region, contact the iTunes Store support staff through the report a problem links in your account history, or via Contact Support.
    tt2

  • On certain web sites(with java applets embedded or rich content),sometimes browser hotkeys are beeing used with other functionality (eg.: youtube uses ctrl + tab for sliding between player controls).How can I prevent this?

    On certain web sites(with java applets embedded or rich content),sometimes browser hotkeys are beeing used with other functionality (eg.: youtube uses ctrl + tab for sliding between player controls).How can I prevent this ?

    Thanks for posting this!
    I would only mention that your definition is incomplete for this -
    Contextual selector A type of Style Sheet Selector that
    and that it's most often referred to now as a Descendent selector, not a contextual selector.  It's basically the same as the Compound selector that you have already defined....

  • I applied some edits to my photo using iOS 7's default photo editor. It looks great when I preview the image on iPhone, but I cannot export the edited photos onto my PC. Anyone know how can I do this?

    I applied some edits to my photo using iOS 7's default photo editor. It looks great when I preview the image on iPhone, but I cannot export the edited photos onto my PC. Anyone know how can I do this?

    yeah, in itunes if you select your phone, you should get tabs across the top for what to sync, under photos uncheck the box
    EDIT: http://support.apple.com/kb/HT4236 is the link to a apple support document with information on syncing photos using itunes.
    Message was edited by: WYSWYG

  • Someone is using my email address to make bookings and apply for loans.  How can I stop this?

    Someone is using my me.com email address to make hotel bookings and apply for loans.  How can I stop this from happening?
    Preferences
    1
    2
    3
    4
    5
    6
    7
    8
    9
    0
    =
    Backspace
    Tab
    q
    w
    e
    r
    t
    y
    u
    i
    o
    p
    Return
    capslock
    a
    s
    d
    f
    g
    h
    j
    k
    l
    shift
    `
    z
    x
    c
    v
    b
    n
    m
    shift
    English
    alt
    alt
    PreferencesSomeoS

    Try and contact your email provider and change your password just in case as a start.

  • HT201318 If you increase your iCloud storage capacity can you increase the number of songs that exceed the 25,000 limit on the iMatch. If it does not apply specifically how can I increase this rather constrained limit?

    The whole business of cloud storage is unclear to me. They say that you have 5G of memory free upgrade to 15 for twenty-five dollars and that this is unrelated to music and video memory. I get this, but I have purchased iCloud Match for $25 but I've quickly maxed out the 25,000 song limit. How can I increase this limit. It is at this point I am unclear about the $25 for 15G additional storage... can this be used to increase iTunes/iCloudmusic storage to increase the music Storage? One would think that apple would make these distinctions clearer. Can anyone carify? Thanks!

    iTunes Match does not use your iCloud account.  Your annual Match subscribtion pays for separate storage to host your iTunes library.  As far as I know, you can't increase the 25,000 song limit.
    If you recently purchased the storage upgrade for this purpose, in the U.S. you could call 1-800-MYAPPLE for a refund if you don't need it.

  • List v = new Vector() how can i write this ?

    List v = new Vector() how can i write this ?
    vector does not 'extends' List rather it 'implements' only ......so how can write this way ? ( polymorphism applies only for 'extends' ).

    my question in a simple way is :
    List some_list extends Vector
    No, List is an interface; Vector is a concrete class. Read the javadocs.
    Vector implements List
    >
    AND
    List some_list implements Vector
    are these two same in behaviour
    our  apart from theoretical differences ?thanks
    Interfaces don't have any implementation; they're pure method signatures. When a concrete class implements an interface, it makes a promise that says "I will provide implementations for exactly these methods. Any client can call a method from the interface and I will do something 'sensible' if I'm written correctly."
    From the point of view of static and dynamic types, there's no difference between interfaces and classes.
    C++ has interfaces, too - they're classes with all pure virtual methods. If you understand how C++ works, the concept shouldn't be hard.
    ArrayList is preferred precisely because it isn't synchronized by default. (You can always make it so using java.util.Collections if you wish later on.) If you don't need synchronization, why pay the performance penalty?

  • I can't pause downloads in the download window. The button is there but pressing it does nothing. How can I fix this??

    I am using Firefox 6.0.2 and I can't pause any downloads. I have both the pause and cancel buttons next to the selected download but cannot use the pause one. I can click it but nothing happens. However, the cancel download button is working. How can I fix this?

    I would first update to the latest version of Firefox & attempt to pause the download as you stated to verify if this resolved the issue.
    1. On the menu bar click the '''Firefox '''menu and select '''About Firefox.'''
    2. The '''About Firefox''' window will open and Firefox will begin checking for updates. If updates are available, they will begin downloading automatically. If Firefox is already up to date, just close the About Firefox window.
    3. When the updates are downloaded and ready to be installed, click '''Apply Update.''' Firefox will be restarted and the updates will be installed.
    Note: Firefox does not automatically update plugins (like Adobe Flash, Quicktime or Java). Update your plugins at [http://www.mozilla.org/en-US/plugincheck/]
    See:
    [[Updating Firefox]]

  • How can i apply quantitative space

    In the web apps,How can i apply quantitative space?

    I mean i wanna apply some disk space for storing
    the various file in java.ok this will not get you far around here. I can interpret that in two ways at least. Please tell me what do you mean from the two questions I will post down here. Writing the number next to the question will be just fine.
    1. Do you want to know where to save the *.java files so these can be used within your web application (in which we understand it is a website we are talking about and j2EE environment)?
    2. Do you want to somehow create a file on the client pc from your web application?
    3. Is this NOT a website application and what you really want to know is how to save a file from Java?
    regards,
    sim085

Maybe you are looking for