Challeging Traversal of Vector and Array

Hi there ! I would like to render the values of this Vector and Array . How do I print it out to the browser ?
try
ResultSet rset = stmt.executeQuery(myQuery);
System.out.println(" Finish Execute Query !!! ");
/* Array Contruction */
int numColumns = rset.getMetaData().getColumnCount();
while (rset.next())
aRow = new String[numColumns];
for (int i=0; i < numColumns; i++){
aRow[i] = rset.getString(i+1);
allRows.addElement(aRow);
return allRows;
}

Hi there !
Thanks for your help but I managed to get it working. For references purposes, I`ll post it here.
My problem now is this :-
How can I issue another SQL statement and store the results in the same array?
Pls note . One Sql per table so, that`s the issue ?
Can someone help with a followup code ?
try
ResultSet rset = stmt.executeQuery(myQuery);
System.out.println(" Finish Execute Query !!! ");
/* Array Contruction */
int numColumns = rset.getMetaData().getColumnCount();
while(rset.next())
// for every record instance aRow
aRow = new String[numColumns];
// store in aRow the values of the record
for(int i=0;i<numColumns;i++)
aRow[i] = rset.getString(i+1);
//When aRow is full store it in the vector
allRows.addElement(aRow);
// when the rset finished print all the Vector
for(int i=0;i<allRows.size();i++)
// get returns a String[]
String[] tmpRow = (String[])allRows.get(i);
for(int j=0;j<tmpRow.length;j++)
out.print(tmpRow[j]+" ");
out.println("");
}

Similar Messages

  • Newbie question about using vectors and arrays

    I'm fairly new to JME development and java in general. I need some help in regards to Vectors and 1 dimensional arrays. I'm developing a blackberry midlet and am saving the queried info i pull back from my server side application with each record saved into the array and subsequently each array saved as an element in the vector, thereby creating a 2D "array".
    However I'm having a problem accessing the elements in the array. Here is a sample of what I mean and where I get stuck:
    Vector _dataTable = new Vector(1, 1);
    String[] r1 = {"a", "b", "c", "d"};
    String[] r2 = {"1", "2", "3", "4"};
    _dataTable.addElement(r1);
    _dataTable.addElement(r2);
    Object temp = _dataTable.elementAt(0); //Save the element as an new object for useNow how do I access the particular indexes of the element of the temp object? Do i need to caste it to an array? Is there another more efficient/easier way I should be storing my data? Any help would be great!
    Edited by: Sotnem2k1 on Apr 1, 2008 7:50 AM
    Edited by: Sotnem2k1 on Apr 1, 2008 7:51 AM

    Thanks for the feedback newark. I have this scenario below:
    // Class for my 1D array
    public class OneRecord {
        private String[] elementData = new String[4];
        public OneRecord() {   
            elementData[0] = null;
            elementData[1] = null;
            elementData[2] = null;
            elementData[3] = null;
        public OneRecord(String v1, String v2, String v3, String v4) {   
            elementData[0] = v1;
            elementData[1] = v2;
            elementData[2] = v3;
            elementData[3] = v4;
        public void setElement(int index, String Data) {
            elementData[index] = Data;
        public String getElement(int index) {
            return elementData[index];
    } Then in my main app I have:
    Vector _dataTable = new Vector(1, 1);
    OneRecord currRecord = new OneRecord("a", "b", "c", "d");
    _dataTable.addElement(currRecord);
    OneRecord temp = (OneRecord)_dataTable.elementAt(1);
    System.out.println(temp.getElement(0)); Are there more efficient data structures out there to save queried data from a server side app? Like I said, i'm still trying to learn the most efficient techniques of coding...esp for the Blackberry. Any suggestions would be great!

  • Vector and Jtree 4Duke

    hi
    i am having poblem with my jtree as i am not able to show the object in my vector as a different node
    {each object is node of my tree}
    unfortunately they all appear flat in the root, and in sequence{as one node} ??
    i have done everything but still no answer??
    thanks in advance for any solution
    public class Gui extends JFrame
    {  Vector root = new Vector();
    public JTree theTree ;
    public SERGui( )
    System.out.println(root.size());//root vector is empty
    roott = new DefaultMutableTreeNode (root);
    model = new DefaultTreeModel (roott) ;
    theTree = new JTree (model);      
    public Vector addOne(String newString)
    if (!root.contains(getQuery))
               root.add(newString);
    model.reload();
    // //updateTree(); i also try this method whiich does not work
    return root;
    public void updateTree(){
    DefaultMutableTreeNode v = (DefaultMutableTreeNode)theTree.getModel().getRoot();
    for(int i=0;i<root.size();i++)
                   DefaultMutableTreeNode node = (DefaultMutableTreeNode)root.elementAt(i);
                   roott.add(node);
    ((DefaultTreeModel)theTree.getModel()).reload(v);
    //DefaultMutableTreeNode node = null;
    print_vector(root);
      //root.clear();
         }and my other class
    where i call this methos is as follow
    Class Search()
    public void countWord(String newString)
    {Gui.addOne(newString);
    }}

    You are passing a Vector into the constructor of the DefaultMutableTreeNode to create the root of your tree. The DefaultMutableTreeNode will use this object's string representation (by calling toString on whatever object you pass in its constructor) as the name of the tree node. So basically you will see the entire contents of the vector as the name of your root node.
    You need to traverse your vector, and use each element to create a DefaultMutableTreeNode and add it to your root node.
    here is the modified code
    public class Gui extends JFrame {
    private Vector rootVector = new Vector();
    private JTree theTree;
    private DefaultMutableTreeNode rootNode;
    private DefaultTreeModel model;
    public Gui() {
    System.out.println(rootVector.size());
    //root vector is empty
    rootNode = new DefaultMutableTreeNode("Root");
    model = new DefaultTreeModel(rootNode);
    theTree = new JTree(model);
    public Vector addOne(String newString) {
    if (!rootVector.contains(newString)) {
    rootVector.add(newString);
    updateTree();
    return rootVector;
    public void updateTree() {
    rootNode.removeAllChildren();
    for (int i = 0; i < rootVector.size(); i++) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(
    rootVector.elementAt(i));
    rootNode.add(node);
    ((DefaultTreeModel) theTree.getModel()).reload(rootNode);
    Hemant Mahidhara

  • Please help, 2D Array of Vectors and Incompatible types :(

    I have a 2D array of vectors called nodeLocations but when I try and access the vector inside I get a compile error.
    My code is something like this:
    nodeLocations[j].addElement(noArc)
    My editor picks up that its a Vector and shows me addElement as an acceptable entry to put after the "." yet the compiler says:
    "addElement(java.lang.Object) in java.util.Vector cannot be applied to (int)"
    Can someone please help?
    Thank you in advance.
    also a related problem:
    I get inconvertible types (says int required) when I try and get an element from a vector stored in a 2D Array. I know that it comes out as an object and so should be cast but it does not seem to work. My code is as follows:
    else if (((int)(nodeLocations[nodeNumber][adjNodeNumber].elementAt(0))) != distance)
    I would appreciate any help anyone can give.
    Similar errors to the above two happen when
    I try a push with a Stack in a vector.
    I try to get something out of the stack inside the vector.

    The Vector class's addElement() method requires an Object parameter. It appears that you're trying to add an int to the Vector. You'll need to create an Integer object and place that into the vector (see sample below) or use the pre-release version of JDK 1.5 which provides autoboxing capabilities.
    int z = 5;
    Integer x = new Integer(z);
    nodeLocations[j].addElement(x);

  • Vector (good for storing) and arrays(good for numerical sums, multiplying)

    Hi guys, I am trying to use vectors because I need a variable lenght and store 2D arrays in one coordenate of a vector. That is why I am using vector instead arrays. I can turn the type of variable using "Integer" (instead of "int" as arrays), "Double" (instead of "double") and so on. The problem is that it doesn't allow me to operate, it is very good for storing, but I need to be able to operate, multiplying, sum, etc the elements there are in the coordenates. And I think it is not possible.
    What u think about it? I can only store stuff ion a vector, I cannot operate. Besides I cant turn a data from "Double" to "double", I can either use arrays OR vectors, but not both of them at the same time.
    You think i am wrong?, because I mean in that case, Java is not very useful to do this numerical problem.
    Thanks.
    This is only a class of the program I am doing.
    import java.util.*;
    class SolveDomain {
         int newton_iter = 0, m = 0, work_count = 0;
         double t = 0, dx, dy, dt, start_t=0;
         double[][] v;
    Details obDetails = new Details();
         public double[][] solveDomainMethod(Double vAxn, Double vAyn, Double vBxn, Double vByn, Integer nxn, Integer nyn, double dt, Double error1n, Double error2n, double end_tn, int stepsn, Integer kcn, Double u_n[][], Double v_n[][], Double bc1, Double bc2, Double bc3, Double bc4, double u[][]) {       
         double dx2, dy2, err = 1000000;
         v = new double[nxn+1][nyn+1];
         DoublevAxn, Double vAyn, Double vBxn, Double vByn, Integer nxn, Integer nyn, double dt, Double error1n, Double error2n, double end_tn, int stepsn, Integer kcn, double u_n[][], double v_n[][], Double bc1, Double bc2, Double bc3, Double bc4;
    double k[][] = new double [nxn+1][nyn+1]; double kp[][] = new double [nxn+1][nyn+1];
    double kpp[][] = new double [nxn+1][nyn+1]; double dudx[][] = new double [nxn+1][nyn+1];
    double dudy[][] = new double [nxn+1][nyn+1]; double d2udx2[][] = new double [nxn+1][nyn+1];
    double d2udy2[][] = new double [nxn+1][nyn+1]; double dudt[][] = new double [nxn+1][nyn+1];
    double a[][] = new double [nxn+1][nyn+1]; double b[][] = new double [nxn+1][nyn+1];
    double c[][] = new double [nxn+1][nyn+1]; double d[][] = new double [nxn+1][nyn+1];
    double F[][] = new double [nxn+1][nyn+1]; double A[][] = new double [nxn+1][nyn+1];
    double B[][] = new double [nxn+1][nyn+1]; double C[][] = new double [nxn+1][nyn+1];
    double D[][] = new double [nxn+1][nyn+1]; double E[][] = new double [nxn+1][nyn+1];
    double s[][] = new double[nxn+1][nyn+1];
              KDerivatives1 obK1 = new KDerivatives1();
              KDerivatives2 obK2 = new KDerivatives2();
    UDerivatives obU = new UDerivatives();
              CalcPdeCoefficients obPde = new CalcPdeCoefficients();
              CalcFdCoefficients obFd = new CalcFdCoefficients();
              Gs obGs = new Gs();
    dx = obDetails.seg(vBxn, vAxn, nxn);
    dy = obDetails.seg(vByn, vAyn, nyn);
    dx2 = dx*dx;
    dy2 = dy*dy;
    if (bc1 != -999999999) obDetails.initialiceBCDomainL(dx, dy, vAxn, vAyn, bc1, u);
    if (bc2 != -999999999) obDetails.initialiceBCDomainU(dx, dy, vAxn, vAyn, bc2, u);
    if (bc3 != -999999999) obDetails.initialiceBCDomainR(dx, dy, vAxn, vAyn, bc3, u);
    if (bc4 != -999999999) obDetails.initialiceBCDomainD(dx, dy, vAxn, vAyn, bc4, u);
    obDetails.source(dx, dy, vAxn, vAyn, s);
    do {
    ++ newton_iter;
    if (kcn == 1) { 
              obK1.calc_k(u, k);
         obK1.calc_kp(u, kp);
         obK1.calc_kpp(u, kpp);
              } else {
                   obK2.calc_k(u, k);
              obK2.calc_kp(u, kp);
              obK2.calc_kpp(u, kpp);
                   obU.calc_dudx(u, dx, dudx);
              obU.calc_dudy(u, dy, dudy);
                   obU.calc_d2udx2(u, dx2, d2udx2);
                   obU.calc_d2udy2(u, dy2, d2udy2);
              obU.calc_dudt(u, u_n, dt, dudt);
              obPde.calcPdeCoefficientsa(k, a);
              obPde.calcPdeCoefficientsb(kp, dudx, b);
              obPde.calcPdeCoefficientsc(kp, dudy, c);
              obPde.calcPdeCoefficientsd(kp, kpp, dudx, dudy, d2udx2, d2udy2, d);
              obPde.calcPdeCoefficientsF(k, kp, dudx, dudy, d2udx2, d2udy2, dudt, s, F);
              obFd.calcFdCoefficientsA(a, b, dx, dx2, A);
              obFd.calcFdCoefficientsB(a, b, dx, dx2, B);
              obFd.calcFdCoefficientsC(a, c, dy, dy2, C);
              obFd.calcFdCoefficientsD(a, c, dy, dy2, D);
              obFd.calcFdCoefficientsE(a, d, dx2, dy2, dt, E);
              obGs.gsMethod(v_n, A, B, C, D, E, F, dt, error2n, v);
              m = m + obGs.iter;
              for (int i=1; i < u.length - 1;i++ ) {
                   for (int j=1; j < u[0].length - 1 ;j++ ) {
         u[i][j] = u[i][j] + v[i][j];
    err = 0;
              for (int i=0; i < u.length ;i++ ) {
                   for (int j=0; j < u[0].length ;j++ ) {
                   err = err + Math.pow(v[i][j],2);
              err = Math.sqrt(err);
    while (err > error1n);
         return u;           
    public double[][] rectangleDomainF (Vector vAxvector, Vector vAyvector, Vector vBxvector, Vector vByvector, Vector nxvector, Vector nyvector, Vector error1vector, Vector error2vector, double end_t, int steps, Vector kcvector, double numberdomains, Vector bc1vector, Vector bc2vector, Vector bc3vector, Vector bc4vector) {
                   double u[][] = new double[u.length][u[0].length];
                   double dt = obDetails.seg(end_t, start_t, steps);
                   Vector uvector = new Vector();
                   Vector vvector = new Vector();
         do
    ++work_count;
              t = work_count * dt;
    for (int k = 0; k < numberdomains ; k++) {
         solveDomainMethod((Double)vAxvector.elementAt(k), (Double)vAyvector.elementAt(k), (Double)vBxvector.elementAt(k), (Double)vByvector.elementAt(k), (Integer)nxvector.elementAt(k), (Integer)nyvector.elementAt(k), dt, (Double)error1vector.elementAt(k), (Double)error2vector.elementAt(k), end_t, steps, (Integer)kcvector.elementAt(k), (Double [][]) uvector.elementAt(k), (Double [][]) vvector.elementAt(k), (Double)bc1vector.elementAt(k), (Double)bc2vector.elementAt(k), (Double)bc3vector.elementAt(k), (Double)bc4vector.elementAt(k), u);
                                                           uvector.insertElementAt(u, k);
              vvector.insertElementAt(v, k);
    while (t < end_t);
    return u;

    The only way to, for instance, multiply a Double object by another Double object is to convert them back to primitives, multiply them, and create a new Double instance:
    public Double multiply(Double lhs, Double rhs) {
       return new Double( lhs.doubleValue() * rhs.doubleValue() );
    }This is just an overhead that you have to accept if you want to use collections with primitive type data.
    Coming soon in 1.5 (which is in Beta now and available for download in the usual places) a new feature called auto-boxing will do a lot of this automatically for you. You need to be aware that it's doing exactly the same operations with the same performance overhead; but it does save a lot of typing.
    Thus in 1.5 the above becomes:
    public Double multiply(Double lhs, Double rhs) {
       // Under the hood this is IDENTICAL to the above example
       return lhs * rhs;
    }Now, addressing your post directly:
    Besides I cant turn a data from "Double" to "double"
    Yes you can, as in the first example, the doubleValue() method converts a Double object to a double primitive.
    Java is not very useful to do this numerical problem.
    If you need math performance, you need to use primitives, yes. Yes, that will preclude the use of collections.
    Dave.

  • Storing resultset data to vector and then passing this data to JList

    hi every body I am facing this problem since two days I tried but could't get correctly,I am new to java and I need to pass the result set data from the database to a JList having JCheckBox
    I think I need to store the resulsetdata to a vector or array
    I tried but could't solve the problem
    I tried but could't get it
    please do help me out
    need some sample code for passing resultset data to JList having JCheckBox anybody please help me out
    thanking you,
    with regards

    hi guys any body please help me out
    need a sample code for the first thread which i had the problems
    trying but could't get that correctly,please please do help me out,
    do help me out as I am new to java need some code snippet java gurus
    thanking you,
    with regards

  • WHY WE USE VECTOR NOT ARRAY STRING

    Hi
    I want to know why we use Vector not bufferstring.
    What is the difference Vector(1,1) and STRING[1][1]?
    Which one we will prefer?
    Why we will prefer one of them?
    Please help me to find out.

    There are huge differences between array and Vector.
    Array is a special class that allows to keep references to a number of Objects of some type. It has a maximum length set during construction, and does not offer any methods to change it's size (without defining a new array).
    Vector is a class (thread-safe unlike it's new version ArrayList) that allows to keep references to any Object (may be of different types). It doesn't have a maximum length set, and can be potentionally of any size. It allows to easily remove, add, insert new elements and keeps all the elements in the order they were added (unless some object was inserted). This is a really well written class, and I'm always using it for storing some objects.
    Hope it was helpful.

  • Easy way to clone a Vector and its Content?

    I have a Vector containing String Arrays. I would like to clone the vector an all it's content.
    Just cloning the vector doesn't work, because just the vector gets cloned whereas the references to the StringArrays in the vector stay the same.
    So i guess i have to clone all the StringArrays too? This would be a very "expensive" process, so i'd like to ask first, if there is another methode to clone a vector and it's content?
    Thanks for your help!

    No. Clone gives you a shallow copy. What you want is a deep copy. However, since Strings are immutable, you only need to deeply copy the string arrays, not the strings themselves. If you were working with mutable objects, this would not be the case and you would need to copy the items in the array as well as the array itself.

  • Vector() and maybe List of Vector() ?

    Is there a java class that creates automatically a list (list,array,or vector) of vector()?
    Thank you for your help.

    I just need to save fields of a graphic interface into a vector and then insert the vector to a list or >something else.
    Do you thing it is a good way to programm if i create an array of vector?To know which is the best data structure for your propose you must have a good knowledge about your problem. You may know your problem, but I don't.
    Choosing a right data structucture will improve the performance of your aplication, plus make the code simpler, the oposite will have oposite results.
    If, for example, big amoust of data will be stored and the need to be procesed in any orther, ArrayList may be a good solution, but if they mus be processed in a specifical order, and no the same order they were added to the ArrayList, this data structure will spoil amazingly the peroformace of your aplication (it happen to me), while HashTable, or HashMap if no synchronization is required, will increase notably your performace.
    Which data struture you should employ?. You known your problem, spend a couple of hours understandind the coollection framework as I'm sure you'll fin a suitable structure which even may save you the tieme you spend undestandind the collection framework by making the code easier.
    Abraham.

  • Vector and HashMap

    what is the complexity of doing a vector.get(position) (vector is a Vector object) ? is it implemented like and have to proceed through the vector til position, or does it jump strigth to the point?
    I have objects whose IDs are integer from 0 to n.
    do I have any advantage using HashMap with ID as key or gievn this property the cost when doing get/set (get/put) operation is the same?
    thanks,
    pao

    Yeah, people can continue to use Vector and ignore
    that someone went through the trouble to create
    something better and probably nothing will be
    affected. I just don't think it's a good way to use a
    tool. True. Though, someone also when through the trouble of making Vector compatible with the List interface. I do agree with you however.
    I also don't understand why HashMap has edged
    out Hashtable but people keep insisting on using
    Vector over ArrayList. I haven't seen where HashMap or Vector have edged out Hashtable or ArrayList respectively. But I suspect that many of the people who learned to use the former classes simply haven't made the leap (perhaps they are not even aware that there is a leap to be made).
    My main problem with Vector is
    that it contains a public interface that is well
    outside of the List interface. Junior developers that
    are not steered away from Vector are more likely to
    miss-out the List interface entirely.Agreed.
    >
    Also, the Java APIs are starting to show their age.
    If Sun decides to make the leap and create a Java
    2.0, they should clean up the JDK. If it were me,
    I'd ax the Vector class. There's no need for two
    array -backed list classes.True, except that it may be necessary for backwards compatibility.

  • Vectors, lists, arrays

    Hi, I'm writing a program using a variable length sequence of boolean values. I will want to manipulate this, altering & reading etc and don't know what will be most time efficient (prog has lots of iterations and takes a while). Any ideas what'd be best for this, vectors, lists, arrays or something else?
    Cheers

    There should be no difference.
    For using List or any Collection interface, you need to use Boolean, the object though.
    You can simplify the storage by just using boolean[], the array, but with "variable length", you have to deal with growing the array. So List is simpler overall.
    --lichu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • All the xml and arrays are getting NULL Problem

    Hello guys
    I am working on a project which uses xml loading, e4x and array manipulation extensively, and it was going good but now I got stuck on a strange problem.  Whole code was fine and application was working and responding in a desired way, but then mystourisly it stopped working and started to retun NULL values to almost all the actionscript (internal) Arrays and XML varibales.
    Now Whenever i load xml file and assign the loaded values to internal xml variables, internal values get only NULL instead of data.
    Same is the situation with Arrays, I created some components in mxml, and when i passed them to arrays by reference, code gets compiled successfully, but again Array has only null values [that code was working fine too]
    I am wondering if Adobe Flex did a silenced update or something similar and it is the result of that things !
    I am using Adobe Flex 3.2 with SDK 3.3 on windows Vista Ultimate.
    Please check this attached project, Import it and see if you face the same problem
    Thanks
    Link to Problem Project
    http://isolatedperson.googlepages.com/problemXperiment.zip
    Problem Screenshot
    http://isolatedperson.googlepages.com/xmlissue.JPG

    Use HTTPService to load the data. You'll have fewer problems.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application creationComplete="dataSvc.send();"
      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
         <mx:Script>
              <![CDATA[
                import mx.collections.XMLListCollection;
                import mx.rpc.events.ResultEvent;
                [Bindable] private var xlc:XMLListCollection;
                   private function loadXML(evt:ResultEvent):void{
                    xlc =  new XMLListCollection(evt.result.individual.@id as XMLList);
              ]]>
         </mx:Script>
         <mx:HTTPService resultFormat="e4x" result="loadXML(event)" url="alirazaTree.xml" id="dataSvc"/>
         <mx:ComboBox id="cbx" dataProvider="{xlc}"/>
    </mx:Application>

  • Difference  between null vector and empty Vector

    What is the diffrence between null vector and empty vector.

    null vector means the JVM doesn't allocate memory.It doesn't exist
    in memory. NO instance!
    empty vector means the JVM allocated memory.It exists in memory.
    it's a instance than is accessabel.But only have on elements.
    GL&HF.

  • Loops and Arrays help

    Hi,
    I'm a freshman in college and new to java. I am completely lost and really need help with a current assignment. Here are the instructions given by my teacher...
    Building on provided code:
    Loops and Arrays
    Tracking Sales
    Files Main.java and Sales.java contain a Java application that prompts for and reads in the sales for each of 5 salespeople in a company. Files Main.java and Sales.java can be found here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Main.java
    and here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Sales.java It then prints out the id and amount of sales for each salesperson and the total sales. Study the code, then compile and run the program to see how it works. Now modify the program as follows:
    1. (1 pts) Compute and print the average sale. (You can compute this directly from the total; no new loop is necessary.)
    2. (2 pts) Find and print the maximum sale. Print both the id of the salesperson with the max sale and the amount of the sale, e.g., "Salesperson 3 had the highest sale with $4500." Note that you don't necessarily need another loop for this; you can get it in the same loop where the values are read and the sum is computed.
    3. (2 pts) Do the same for the minimum sale.
    4. (6 pts) After the list, sum, average, max and min have been printed, ask the user to enter a value. Then print the id of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of salespeople whose sales exceeded the value entered.
    5. (2 pts) The salespeople are objecting to having an id of 0-no one wants that designation. Modify your program so that the ids run from 1-5 instead of 0-4. Do not modify the array-just make the information for salesperson 1 reside in array location 0, and so on.
    6. (8 pts) Instead of always reading in 5 sales amounts, allow the user to provide the number of sales people and then create an array that is just the right size. The program can then proceed as before. You should do this two ways:
    1. at the beginning ask the user (via a prompt) for the number of sales people and then create the new array
    2. you should also allow the user to input this as a program argument (which indicates a new Constructor and hence changes to both Main and Sales). You may want to see some notes.
    7. (4 pts) Create javadocs and an object model for the lab
    You should organize your code so that it is easily readable and provides appropriate methods for appropriate tasks. Generally, variables should have local (method) scope if not needed by multiple methods. If many methods need a variable, it should be an Instance Variable so you do not have to pass it around to methods.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this.
    I'm not asking for someone to do this assignment for me...I'm just hoping there is someone out there patient and kind enough to maybe give me a step by step of what to do or how to get started, because I am completely lost from the beginning of #1 in the instructions.
    Any help would be much appreciated! Thank you!
    Message was edited by:
    Scott_010
    Message was edited by:
    Scott_010

    First ask the person who gave this asignment as to why do you require two classes for this , you can have only the Sales.java class with main method in it . Anyways.
    Let Main.java have a main method which instanciates a public class Sales and calls a method named say readVal() in Sales class.
    In the readVal method of sales class define two arrays i.e ids and sales. Start prompting the user for inputting the id and sales and with user inputting values keep storing it in the respective arrays .. Limit this reading to just 5 i.e only 5 salesPerson.
    Once both the arrays are populated, call another method of Sales class which will be used for all computations and output passing both the arrays.
    In this new method say Compute() , read values from array and keep calculating total,average and whatever you want by adding steps in just this loop. You can do this in readval method too after reading the values but lets keep the calculation part seperate from input.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this. I think this is ur personal stuff , but if you want to use web page , you probably will require to use servlet to read values from the html form passed to the server.

  • Returning vector and null pointer exception

    Hi, I'm writing a mailing program which so far is working fine, but I have now run into a problem which is completely throwing me. My mailer needs to be able to load multiple attachments - and also to be able to deal with an HTML text which contains multiple images. In each case, what I'm trying to do is to put the attachments and the images into separate vectors and process them through an iterator. The logic, at least, I hope is correct.
    I can get my code to compile but it keeps throwing a null pointer exception a runtime. Somehow, I just can't get it to pass the vector from one part of the code to another.
    Can anyone help me? I've tried various things, none of which seem to work. My code, as it stands, is posted in a skeletal form below.
    Thanks for any ideas:
    public class MailSender
       // declare various variables, including:   
         Vector embeddedImages;
         String HTMLString;
        public MailSender()
            setup();
        private void setup()
         //this part of the program sets up the various parts of the mail  (to, from, body etc)    
          HTMLString = "blah blah blah";  //sample HTMLString   
           Vector embeddedImages = null; //is this correct?
            if (HTMLString.length() > 0)
                processHTMLString(HTMLString);
         private String procesHTMLString(String htmlText)
            Vector embeddedImages = new Vector(); // I construct my vector here, is this correct?
            //Here I process the HTML string to extract the images
            //get the file path of the image and pass it to the vector
            addToVector(imageFile);
            return HTMLString;
        public Vector addToVector(String imageFile)
            embeddedImages.add(imageFile);
            return embeddedImages;
        private void send()
            //this part does the sending of the mail
            //at some part in this method I need to get at the contents of the vector:
            //but this part isn't working, I keep getting a null pointer exception
            Iterator singleImage = embeddedImages.iterator();
            while (singleImage.hasNext())
        public static void main(String[] args)
            MailSender ms = new MailSender();
            ms.send();
            System.out.println("MailSender is done ");
    }

    >>>>while they don't have a clue on how the language and/or programming in general works.
    Thank you, salpeter, for your esteemed estimation of my programming competence.
    >>>What I'm wondering is: how come people always start building applications... blah blah
    The reason being, is that it happens to be my job.
    OK, I'm perhaps slower than most and there are things I don't yet understand but I get paid probably about a tenth of what you do (and maybe even less). I regard it as a kind of apprenticeship which, after a past life having spent twenty years packing crates in a warehouse, is worth the sacrifice. Six months ago I'd never written a line of code in my life and everything I've learned since has been from books, the good people in these forums, and a lot of patient trial and error. It's hard work, but I'll get there.
    I say this, only as encouragement to anyone else who is trying to learn java and hasn't had the benefit of IT training at school and a four year computing course at university paid for by the parents, and for whom the prohibitive cost (in both time and money) of most java courses would never allow them to get on this ladder.
    Excuse my somewhat acerbic posting, but comments such as yours tend to provoke...
    Thank you EverNewJoy for explaining this to me. I haven't had time yet to try it out, but at least the concept now is clear to me.

Maybe you are looking for

  • Is the iPad camera connection kit compatible with iPod touch 4?

    It has the 30 pin connector, so it it compatible with iPod touch 4?

  • Understanding the messages in /var/adm/messages

    Hi, Please let me know what does these error messages mean? May 15 00:03:00 bir_sys1 utdevmgrd[14281]: [ID 331289 daemon.error] dm getpeername: Transport endpoint is not connected May 15 00:03:00 bir_sys1 utdevmgrd[14281]: [ID 273529 daemon.notice] Q

  • Best Solution for Managing Music

    I would like to hear some advice/suggestions for managing my digital music files. I have a small iPod, only 16GB, but I don't like to use a lot of disk space on my computer to keep music files. What are some of my best options for organizing my digit

  • Apple screen capture prefs

    Re-the Apple screen capture feature (command Shift 4) being unable to survive more than a few seconds, I seem to recall Michael Henley writing something about the possibility of a corrupted pref file. I could only find those 2: •Myname>library>Prefs>

  • Office 2008 , ATP ?

    I bought the latest office 2008:mac, there is no analysis tool pack with office 2008. is it hidden or changed to other toolbar ?