Class Vector

how can i make a list of comands in a vector and them use them in a text editor ?

You need to be a little more explicit about what you're doing, what you expect to happen, and what you actually observe.
Please post a short, concise example. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that.
Post your code between [code] and [/code] tags as described in Formatting Help on the message entry page. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please Preview your post when posting code.
Please post a compileable and executable example. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.
Please assume that we only have the core API. We have no idea what SomeCustomClass is, and neither does our collective compiler.
If you have an error message, post the exact, complete error along with a full stack trace, if possible. Make sure you're not swallowing any Exceptions.

Similar Messages

  • What means the " E " in class Vector and " T " in class Class?

    Hi world!
    I was searching in the java docs and in the source code of Java and found a syntaxis that I don't know what mean. This:
    public class Vector<E>
        extends AbstractList<E>
        implements List<E>, ...and this:
    public Vector(Collection<? extends E> c)this too:
    public final
        class Class<T> impleme...and that:
      public static Class<?> forName(String className) well you get the idea. If someone could give me where can I find information about the using of this.
    Tanks

    See the generics tutorial:
    http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

  • Class vector can't be resolved

    hi ,
    plz i got the following error while running a J2ME
    program
    cannot resolve symbol
    symbol : method add (java.lang.String)
    location: class java.util.Vector
    any ideas????

    First of all, crosspost:
    http://forum.java.sun.com/thread.jspa?threadID=629578
    Please only use one thread.
    There is no method "add(someStringVariable)" in the Vector library for j2me. However, there is "addElement (Object o)".
    j2me specs and j2se specs are very different.
    J2ME leaves out alot of methods due for mobile usage.
    To get specs for cldc and midp, look here:
    http://java.sun.com/j2me/docs/index.html

  • Putting a Class Object into a Vector

    HI all
    I need to put a class object into another classes vector, then be able to read it and retrieve data.
    I can put the object into the vector but all i seem to be able to retrieve is data like Account@2343c2.
    Is this some sort of tag? How do i get to the data?
    thankz
    joey

    That's what you get when you print an object which does not have its own toString() method to do anything different - it picks up the Object class's toString method instead. For example:
    System.out.println(new Object());It sounds like you're doing something like this:
    Vector v = new Vector();
    v.add(new Account(42));If you were to do the following, you would see that sort of output:
    System.out.println(v.get(0));The appropriate way to do this would be something like the following:
       // Use a List reference instead of a Vector reference, and create
       // an ArrayList object in preference to a Vector object
       List list = new ArrayList();
       list.add(new Account(42));
       // Iterate through the list of accounts - use an
       // iterator because this prevents off-by-one errors
       // that arise with direct indexing.
       Iterator i = list.iterator();
       while(i.hasNext()) {
          // Cast the reference returned by the iterator from
          // Object to Account so that we can call account-specific
          // methods.
          Account current = (Account)i.next();
          // Call the method specific to the Account class (getBalance
          // is just an example that I made up).
          System.out.println(current.getBalance());
       }

  • How to Call vector in Jsp from My factory class

    Hi all,
    I am new to singleton,I written a singleton class,One more all so name is getAllFactory(),this method returns vector which i am going to adding my data to xxDto finally i am adding this xxDto to my Vector in the singleton class.
    I need help how to call that vector in my jsp page...can any body plzz suggest to me.
    Thanks
    dilse

    import your singleton class to your JSP using page directive.
    And also import Vector class.
    Then as usual create object to vector class
    Vector v = singletonClassObject.getAllFactory()
    thats enough.

  • How can I extend the Vector class?

    Hi All,
    I'm trying to extend the Vector class so I can get add a .remove(item:T) method to the class.  I've tried this:
    public class VectorCollection extends Vector.<T>
    That gives me the compile error "1017: The definition of base class Vector was not found"
    So then I tried:
    public class VectorCollection extends Vector
    Which gives me the compile error "1016: Base class is final."
    There must be some way to extend the Vector class, though, as on the Vector's official docs page it says:
    Note: To override this method in a subclass of Vector, use ...args for the parameters, as this example shows:
         public override function splice(...args) {
           // your statements here
    So there must be a way to extend the Vector class.  What am I doing wrong?

    No. AS3 doesn't currently have full support for generic types; Vector.<T> was added in an ad-hoc ("ad-hack"?) way. We are considering adding full support in a future version of ActionScript.
    Gordon Smith
    Adobe Flex SDK Team

  • Storing information in a Vector from a file.

    When I try to compile the following program below, I am receiving three error messages stating:
    1) Reference to Variable size as if it was a method.
    2) Method elementAt(int) not found in vector class.
    3) Method addElement(Movie) not found in vector class.
    Is it possible for somebody to give me some feedback in reference to solving my problem?
    import java.io.*;
    import java.util.*;
    public class Main_vector{
    public static void main(String argv[])throws IOException{
    Vector main_vector = Vector.read_vector("In.file");
    int size = main_vector.size();
    for(int counter = 0;counter < size;++counter){
    System.out.println("Information in vector "+ ((Movie)main_vector.elementAt(counter)).rating());
    import java.io.*;
    import java.util.*;
    public class Vector{
    public static Vector read_vector(String filename)throws IOException{
    FileInputStream stream = new FileInputStream("In.file");
    InputStreamReader reader = new InputStreamReader(stream);
    StreamTokenizer tokens = new StreamTokenizer(reader);
    Vector v = new Vector();
    while(tokens.nextToken() != tokens.TT_EOF){
    int x = (int) tokens.nval;
    tokens.nextToken();
    int y = (int) tokens.nval;
    tokens.nextToken();
    int z = (int) tokens.nval;
    v.addElement(new Movie(x,y,z));
    return v;
    }

    1) Reference to Variable size as if it was a method.
    Are you sure you get this? Where?
    2) Method elementAt(int) not found in vector class.
    your own Vector class hides java.util.Vector so you need to use java.util.Vector whenever you mean java.util.Vector and use Vector whenever you mean your own Vector class
    3) Method addElement(Movie) not found in vector class.
    same as above

  • I need help an urgent help in vectors

    I am comparing the elements of one vector with everyother element of another vector.If a match is found I need to remove the element from the second vector and should obtain the remaining elements of the second vector.Could u please help in this!
    ie)
    Vector v1=new Vector();
    Vector v2=new Vector();
    v1.addElement("apple");
    v1.addElement("grapes");
    v1.addElement("mango");
    v1.addElement("orange");
    v1.addElement("pineapple");
    v1.addElement("banana");
    v2.addElement("cherry");
    v2.addElement("berry");
    v2.addElement("papaya");
    v2.addElement("mango")
    v2.addElement("apple");
    here in this example , if i compare the vectors (v1,v2), the elements in v2(mango and apple) are contained in v1 also.so i need to remove the elements from vector v2 which are common and need to fetch the remaining elements in the v2 vector.so the resulting v2 vector should contain only 'cherry','berry','papaya',and i need to display the content of v2 vector after the removal of similar elements .could u please help me how to do this!!!!!.

    Much easier way, use Vector.removeAll(Collection c).
    As class Vector is an instance of interface Collection, you can pass in a vector.
    i.e.
    import java.util.*;
    public class tester
         public static void main(String[] args)
              tester.refineList();
         public static void refineList()
              Vector v1=new Vector();
              Vector v2=new Vector();
              v1.addElement("apple");
              v1.addElement("grapes");
              v1.addElement("mango");
              v1.addElement("orange");
              v1.addElement("pineapple");
              v1.addElement("banana");
              v2.addElement("cherry");
              v2.addElement("berry");
              v2.addElement("papaya");
              v2.addElement("mango");
              v2.addElement("apple");
              v2.removeAll(v1);
              for(int a = 0; a < v2.size(); a++)
                   System.out.println(v2.elementAt(a).toString());
    }Hope this helps
    D

  • Problems with protected access in java.util.vector

    Hi,
    basically i'm trying to use the method removeRange(int,int) of class Vector from the java API.
    I keep getting the following compiler message:
    removeRange(int,int) has protected access in java.util.vector.
    This seems rather vague, and i don't know quite what to do?
    Thanks in advance

    removeRange(int,int) has protected access in java.util.vector.
    This seems rather vague, and i don't know quite what to do?As error messages go, that's pretty clear: method removeRange is a protected method and you can only call public ones of Vector, right? You can always combine subList and clear:
    vec.subList(fromIndex, toIndex).claer();

  • Saving and Restoring a class using Persistence Delegate

    Hi, I have a class that does not comply to the java bean format and thus I have decided to use persistence delegates. All I want to do is be able to save an entire class so I can restore it later.
    So this is what I did:
    XMLEncoder xe = new XMLEncoder(
    new BufferedOutputStream(
    new FileOutputStream(filename)));
    xe.setPersistenceDelegate(Workspace.class,
    new PersistenceDelegate()
    protected Expression instantiate(Object oldInstance, Encoder out)
    return new Expression(oldInstance, oldInstance.getClass(),
    "new", new Object[]
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance
    xe.writeObject(workspace);
    xe.close();
    Where workspace takes in a BufferedImage, int, int, int, int, int, String and String.
    The workspace class Vectors and an array of another class of mine.
    When I run this code I get : java.lang.StackOverflowError
    Can someone point me in the right direction please?
    Thanks in advance,
    Harley.

    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.

  • Forcing a vector to become an array.

    I have a method I want to call that returns a vector of generic object instances. I want it to return an arraylist of instances of my specific class.
    neighbors = netGrid.getVonNeumannNeighbors(x, y, false);//vector my VN neighbors. Where neighbors is a class vector. I'd like neighbors to be a local arraylist. Is there a way to do this? I've tried casting neighbors as an array, but since getVonNeumannNeighbors returns a vector, this obviously didn't work, as I've found out.

    Perhaps I should have included the whole method so you can see the problem.
         public void creatingEdges() {
              neighbors = netGrid.getVonNeumannNeighbors(x, y, false);//vector my VN neighbors.
              ArrayList <Node> temporary = new ArrayList <Node>();
              for ( int i = 0; i < neighbors.size(); i++ ){//for every neighbor node stored in neighbors
                   Object o = neighbors.get(i);//get an object out of the vector.
                   System.out.println("Object #" + i  + " is a " + o.getClass().getName());//check that it's a node..
                   if (o instanceof Node) {//if it is
                        temporary.add((Node) o); //add it to the temporary array list
                   for (int j = 0; j <temporary.size(); j++) {//for all the neighbors in temporary
                        Node neighborNode = new Node();// cast it as a Node 
                        System.out.println("the neighbor node's ID is " + neighborNode.getID());
                        if (neighborNode.getEdgesFrom(this) == null){//if the neighbor node doesn't have an edge FROM this node
                             Edge anEdge = new Edge(); //make a new edge.
                             anEdge.setFrom(this);//send a new edge from this node
                             anEdge.setTo(neighborNode);//connect that edge to the neighbor.
                             this.addOutEdge(anEdge);//tell this node it's got a new out edge.
                             neighborNode.addInEdge(anEdge);//tell the neighbor node it's got a new in edge.
         }While the method is still a work in progress, I'd like to use an array list instead of a vector, since then I can get rid of half the crap in this method. Here's the API for the problem method: http://repast.sourceforge.net/api/uchicago/src/sim/space/Object2DGrid.html
    Can it be cast as an array?

  • Concrete classes implement abstract class and implements the interface

    I have one query..
    In java collection framework, concrete classes extend the abstract classes and implement the interface. What is the reason behind extending the class and implementing the interface when the abstract class actually claims to implement that interface?
    For example :
    Class Vector extends AbstractList and implements List ,....
    But the abstract class AbstractList implements List.. So the class Vector need not explicitly implement interface List.
    So, what is the reason behind this explicit definition...?
    If anybody knows please let me know..
    Thanx
    Rajendra.

    Why do you post this question again? You already asked this once in another thread and it has been extensively debated in that thread: http://forum.java.sun.com/thread.jsp?forum=31&thread=347682

  • What is the workflow to compile and load an external class as a runtime library?

    I have a set of classes (with some large embeds) that I only want to load one by one at runtime as needed.
    I think that I need to compile each of these classes into a separate SWF and use one of the available loaders out there to load and link to them dynamically at runtime (am I on track so far?).
    I got a little mixed up in the details though, so I'd just like someone to give me the basic rundown on doing this, get the right termonology, and if you have any reference to the right tutorial on doing it, all the better!
    I'm using flex builder, and this is to be used in a flex application.
    Thanks!
    David

    Hi, thanks for the response!
    A couple of questions arise:
    1) If I use this approach am I correct in my understanding that all classes referenced by my library will be compiled into the final SWF? That will create a lot of duplicated classes since those classes are already being used and loaded in the main SWF. Is there a way to avoid this duplication problem?
    2) In trying to play with this approach I ran into a problem. When I create the SWF it fails to find a class Vector ("Type was not found or was not a compile-time constant: Vector"), I think I understand that this is because I am targeting flash player 9, but the code I am using require 10. I can't seem to find an option to change the target in a flex library project as I can in a regular actionscript or MXML project.
    Dave

  • Vector in jsp

    Hi
    In my jsp a have this part of code
    Vector vcTeamIds = new Vector();
    Vector vcTeamNames = new Vector();
    do{  // column headers adding to vector and displaying
    vcTeamIds.addElement(stb1.getField(stb1.TEAM_ID));
    vcTeamNames.addElement(stb1.getField(stb1.TEAM_NAME));
    } while (stb1.next()); %>
    and I get this error
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 40 in the jsp file: /statistik/kampoversigt.jsp
    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] /opt/jakarta-tomcat-4.1.24/work/Standalone/localhost/services/statistik/kampoversigt_jsp.java:181: cannot resolve symbol
    [javac] symbol : class Vector
    [javac] location: class org.apache.jsp.kampoversigt_jsp
    [javac] Vector vcTeamIds = new Vector();
    [javac] ^
    then I changed it by prefixing it with java.util like this
    java.util.Vector vcTeamIds = new java.util.Vector();
    java.util.Vector vcTeamNames = new java.util.Vector();
    do{  // column headers adding to vector and displaying
    vcTeamIds.addElement(stb1.getField(stb1.TEAM_ID));
    vcTeamNames.addElement(stb1.getField(stb1.TEAM_NAME));
    } while (stb1.next()); %>
    and then I this error
    Can't find resource for bundle java.util.PropertyResourceBundle, key virtualpath
    in the catalina.out and tomcat dies.
    Please tell me what's wrong.
    Lotte

    Both when I prefix it or when I import the java.util I get the same error
    Can't find resource for bundle java.util.PropertyResourceBundle, key virtualpath
    in the catalina.out and tomcat dies
    on the web I just get
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
    More information about this error may be available in the server error log.

  • Synchronization in Vector

    I read that the class Vector is synchronized, but does this mean that it automatically synchronizes access from different threads or is it another feature?
    If it is another feature, do I have do synchronize both the Vector as the elements that it contains? Thank you for the answer!
    BlueRibbon

    it means it's thread safe. for the other collections have a look at Collections.synchronizedSet( ... ) and the like methods.
    robert

Maybe you are looking for