Strings, vector output? HELPP!!!

Hi!
How would I Store strings thats entered from the command prompt into a vector and print them out?
I've been trying to do this for 2 days.....I have erased my code and burnt my sorry java book that really sucks! If anyone could help me I would really appreciate it. Thanx.

I'm assuming this is a J2SE 1.5.0 question, so I'll
use as many of the new language features as I can.
import java.util.*;
public class Vec {
public static void main(String... args) {
Vector<String> vec = new Vector<String>();
for (String s : args) vec.add(s);
System.out.printf("%s%n", vec);
What about using import static java.lang.System.*; and hence out.printf("%s%n", vec); Isn't this a new language features that you are able to use?

Similar Messages

  • String[] array = (String[])vector.toArray();

    Why does the last line cause a ClassCastException?:
    Vector vector = new Vector();
    vector.add("One");
    vector.add("Two");
    vector.add("Three");
    vector.add("Four");
    vector.add("Five");
    String[] array = (String[])vector.toArray();
    Thanks
    [email protected]

    Because toArray () creates an Object array. You need the toArray(Object[]):String[] array = (String[]) vector.toArray (new String[vector.size ()]);Kind regards,
      Levi

  • Vector Output from PSE?

    I have PSE 6.0 on a WinXP machine. My question has to do with producing vector output files using only PhotoShop Elements.
    PSE is capable of producing PDF files as output. My understanding is that PDF files are vector rather than raster. In Elements shapes and type are drawn as vector so does it follow that saving an image which only includes shapes and type as a PDF result in a PDF with the type and shapes as vectors? In other words is the vector information to draw type and shapes saved in the PDF file using Save As?
    Steve

    PSE will normally let you make a backup or data disk on CD.
    What is the purpose of this CD?
    If you also have Premiere Elements, its possible to burn a DVD which can then be viewed on TV sets.

  • Converting Vector output to Excel Format

    Hi All,
    I hv developed a report module using Swing. I hv the output from DB to Vector. I hv to save the output in a excel file in a ordered way. How can i do this. Is there anyway of doing it.
    Kindly help me.
    Thanks
    Srini

    There is [url  http://www.andykhan.com/jexcelapi/index.html]JExcelApi , also Apache POI and so on, but just search the forum for "excel" and you will find that you are not the only one to ask this, there are lots of results that should guide you in your choice.
    HTH
    Mike

  • PowerShell: Want to get the length of the string in output

    Hi All,
    I am typing this but it is not working. Does anyone know what I could be doing wrong.
    The command I wrote is:
                         GCI -file  | foreach {$_.name} | sort-object length | format-table name, length
    But it is not working. I am expecting a name of the file and length of the string like 8 characters etc. my file is called mystery so it should have 7 as its output of the name, length.
    Thank-you
    SQL 75

    Get-ChildItem supports both  -File and -Directory.
    Help will help:
    https://technet.microsoft.com/library/hh847897(v=wps.630).aspx
    Read the first couple of parameters to see.
       GCI -file  | sort-object length | format-table name, length | ft -auto
    Seems to be a rasher of bad answers to day.  YOu were just extracting the name property then trying to sort on a property that doesn't exist.
    Do the sort first then select the properties.
    it helps to test answers before posting.  I know because I get bit by posting without thinking to often.  I have to remember to think first.
    ¯\_(ツ)_/¯

  • How to cut string from output

    I have a program which will pullout the software list of a machine but in output it will display full path with software list buti need only softwarelist how to get it please help me
    try{
              String cmd = "reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\"";
                   //\Microsoft"+"\\Windows\\CurrentVersion\\Uninstall\"";
    // This one will show you software categories installed
    //String cmd = "reg query \"HKEY_LOCAL_MACHINE\\Software\"";
    Process p = Runtime.getRuntime().exec(cmd);
    Thread.sleep(200l); //terrible, the right way is p.waitFor
    //p.waitFor(); /* this command sometimes hangs on windows !!!???*/
    InputStream in = p.getInputStream();
    byte[] bytes = new byte[16384];
    StringBuffer buf = new StringBuffer();
    while(true) {
    int num = in.read(bytes);
    if(num == -1) break;
    buf.append(new String(bytes,0,num,"UTF-8"));
    System.out.println(buf.toString());
    output is:
    HKEY_LOCAL_MACHINE\SOFTWARE
    (Default) REG_SZ
    HKEY_LOCAL_MACHINE\SOFTWARE\Adobe
    HKEY_LOCAL_MACHINE\SOFTWARE\ahead
    HKEY_LOCAL_MACHINE\SOFTWARE\Alps
    HKEY_LOCAL_MACHINE\SOFTWARE\AMD
    HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation
    HKEY_LOCAL_MACHINE\SOFTWARE\ATI
    HKEY_LOCAL_MACHINE\SOFTWARE\ATI Technologies
    HKEY_LOCAL_MACHINE\SOFTWARE\Audible
    HKEY_LOCAL_MACHINE\SOFTWARE\AVG
    HKEY_LOCAL_MACHINE\SOFTWARE\AVG Security Toolbar
    HKEY_LOCAL_MACHINE\SOFTWARE\Azur

    The string class has a replaceAll method: http://download.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29
    Juts replace "HKEY_LOCAL_MACHINE\SOFTWARE\" with "" (empty string).
    Timo

  • Search a String Vector for String

    I can't figure out why this won't work. It is supposed to search the id vector for stringValue. It does not return any compilation errors, it just simply won't match stringValue with the id.get(i) method.
            for ( int i = 0; i < id.size(); i++ )
              if ( stringValue == id.get(i) )
                JOptionPane.showMessageDialog( null, "Item already exist.", "Error", JOptionPane.ERROR_MESSAGE );
                stringValue = null;
            }

    "==" tests for object equality (i.e., that two variables contain the exact same object)
    "equals()" tests for object equivalence (i.e., that two objects have the same value, whether or not they are the same object)
    For strings, it's possible to have two different strings to contain the same sequence of characters. In this case, "==" returns false, while "equals()" returns true.

  • Format string literal output?

    Trying to format the output of sqlplus for a string literal, but can't seem to get it to work. If I SELECT a literal, the literal column's width is always 32 characters long. Kinda makes things look a bit wonky.
    For instance, if I try:
    SELECT ',' FROM DUAL
    My output looks like this:
    It's a bit frustrating when I'm trying to do something like:
    SELECT lastname, ',' , firstname from mytable;
    I'll COL lastname FORMAT to my heart's desire, but not luck.
    Weird thing is that two of my servers are behaving differently. They should be set up the same, but obviously there's some environment setting or something that's different. On the "good" server, that one "SELECT ',' from dual;" query returns this:
    Any ideas?
    Edited by: user9526990 on Mar 12, 2009 2:38 PM
    Ok, so the WYSIWYG editor is overriding my formatting. That horizontal line above should just be 32 consecutive hyphens (--- etc), but it's rendering it as a line.
    Edited by: user9526990 on Mar 12, 2009 2:39 PM

    In all honesty, I think I could just concatenate it and call it good, but at this point I'm just wondering why it doesn't work the same way on both servers.
    What happens is that we have a scheduled job that runs this query every night and dumps the output into a file that's used by some other processes:
    whenever oserror exit sql.oscode
    whenever sqlerror exit sql.sqlcode
    spool D:\output\file.txt
    set pages 0
    set lines 80
    set head off
    set echo off
    set verify off
    set feedback off
    column owner format a20
    column table_name format a33
    column mycolumn format a12
    select l.owner,',', l.table_name,',', l.mycolumn from tablename l;
    spool off
    exit
    Frankly, that snippet's been with the company longer than I have, so I'm not sure why the original author opted for this method rather than just concatenating. But, as I mentioned, I'm more curious about why it doesn't behave the same way on both boxes now.

  • When will Flash CC support vector output?

    Using CS6 is awful on a retina monitor, and isn't a valid long-term solution.

    Adobe need  to address this issue. I used to rely heavily on ai export from Flash which worked fine in earlier versions. Now there seems to be no route to get vector stills from Flash. The SVG output in CC2014 although slow and clunky was OK - but doesn't now work - < I get a JS error..>. now that's left me with a huge problem... I pay good money for CC every month - and I'm a lifelong Adobe fan - but I think their product support (via CC app update) of late has become very shoddy - Adobe: these are professional products for which professional subscriptions are being paid.. you've taken years to build up your reputation - so please - SORT these issues! 

  • Vector output madness - horizontal lines that look like bad field rendering?

    Hi all,
    Has anyone run into this rendering problem using ONLY vector graphics? It looks like a field rendering problem but all I can find on that subject is with regard to film footage. I've tried continuous rasterization and still no joy. Using a Mac, running AE CC2014, output to Quicktime HD 1080i 25fps .mov format. These "cells" are part of a Cannon Particle Playground effect if that makes any difference at all. It was all looking perfect until the render. So frustrating.
    Anyone have experience with this?? Going out of my mind...
    Lisa

    Quicktime HD 1080i 25fps
    i as in interlaced?! You know....
    Mylenium

  • Vector output??

    Im adding a double to the vector, however, when printing out the vector i get the following result.
    [Token[EOF], line 135, Token[EOF], line 135, Token[EOF], line
    135, Token[EOF], line 135, Token[EOF], line 135, Token[EOF], line 135, Token[EO
    F], line 135, Token[EOF], line 135, Token[EOF], line 135]
    heres the code snippet.
    if((StreamTokenizer.TT_NUMBER == token.ttype))v.addElement(token);
    When I print them out 1 by 1 without adding them to a vector I get the results Im hoping for i.e numbers!!
    Anyone know how I can resolve this?
    Cheers for any hints, tips, answers and anything else you care to add!! ;)

    An easy way is to cut them of yourself:
    String s = v.toString();
    s = s.substring(1, s.length()-1);Or you can make your own method to create the string:
    StringBuffer buf = new StringBuffer();
    Iterator e = v.iterator();
    //buf.append("[");
    int maxIndex = v.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
        buf.append(String.valueOf(e.next()));
        if (i < maxIndex)
         buf.append(", ");
    //buf.append("]");
    String result = buf.toString();I just toke the code from the toString() method in AbstractCollection which the Vector inherits from. And I commented out the lines with the squared brackets.

  • Vector output problem

    hi all
    please see code:
    public static Vector magnetWireDia(Vector<Double> secGa)
                        Vector secWD=new Vector();
                   for (int x=0; x<secGa.size(); x++){
                        secWD.add(x,.46/(Math.pow (1.1229322,((secGa.elementAt(x)+3)))));
                        System.out.println("Wire dia="+secWD + "to position="+x);
                        return secWD;
    could you explain why the output is Wire dia=[0.03589054502043804]to position=0
    Wire dia=[0.03589054502043804, 0.05706820267117022]to position=1
    Wire dia=[0.03589054502043804, 0.05706820267117022, 0.025346584597928244]to position=2
    when i was expecting one wire dia in each position.
    thanks
    tvolly

    replace
    System.out.println("Wire dia="+secWD + "to position="+x);with
    System.out.println("Wire dia="+secWD.get(x) + "to position="+x);

  • Crop to artboard (need vector output)

    Greetings,
    Essentially, I need to crop some work to the artboard.  All of the suggestions I've read so far include the export option but I need this design to import into Flash.  My instructor will not permit anything but vector drawings.  I can't export to any sort of raster format or pdf.  Ideally, it needs to remain as an ai file.  When I do the import from Flash, it keeps everything outside the bounds of the artboard (highlighted in red on my screenshot).
    This is a group project. I didn't do this drawing, I just wanted to add the perspective lines to the floor.  Now it's a bit of an untidy mess when it goes to Flash.  And Illustrator is not my strong point.  I did try unsuccessfully to "erase", Scissor, knife and a few other things but I really don't know how those tools work.  I also tried the clipping mask approach but it didn't want to combine my rectangle "mask" with the lines on the floor.
    I'm using AI CS4 and Flash CS6.  Any help would be greatly appreciated.  Thank you.

    Make sure that either there is no selection at all or only the lines are selected.
    edit: When learning tools and they don't work as expected, it is a good idea to try them by creating a new document with a very simple content. For example Create a new document, take the Line tool, draw a few lines, and try to erase them as I suggested. If it works there at least you will see and know how it works and if it doesn't work on another document you will know that there is something in that document that makes things different and you can try to figure out what it is.
    The difference between Clipping Mask and Eraser is that the Clipping Mask hides the unwanted parts while the Eraser actually removes them which may not matter for your case.

  • String column output concate using select

    <pre>
    Hi,
    I've created a table like below details:
    create table name(
    seq number(2)
    name varchar2(100)
    Insert into name (SEQ, NAME) Values (1, 'CHARLES CLARKSON');
    Insert into name (SEQ, NAME) Values (2, 'CAROLINE SINCLAIR CLARKSON');
    COMMIT;
    select * from name;
    SEQ      NAME
    1     CHARLES CLARKSON
    2     CAROLINE SINCLAIR CLARKSON
    Now I want the output of name to be concatenated using a query, separated by comma(,). So I want the result as below:
    NAME
    CHARLES CLARKSON,CAROLINE SINCLAIR CLARKSON
    Is there any way we can achieve this concat?
    Thanks
    Deepak
    </pre>

    Like this:
    SQL> ed
    Wrote file afiedt.buf
      1  select rtrim(xmlagg(xmlelement(e,user_name||',').extract('//text()')),',') username
      2* from (SELECT user_name from table1 where rownum < 5) e
    SQL> /
    USERNAME
    MCNILA,BINGHA,AMORA,AMARK
    SQL>
    SQL> ed
    Wrote file afiedt.buf
      1  select rtrim(xmlagg(xmlelement(e,user_name||',').extract('//text()')),',') username
      2  from (SELECT 'CHARLES CLARKSON' user_name from dual
      3        union select 'CAROLINE SINCLAIR CLARKSON' from dual
      4*       union select 'FIRSTNAME LASTNAME ' from dual) e
    SQL> /
    USERNAME
    CAROLINE SINCLAIR CLARKSON,CHARLES CLARKSON,FIRSTNAME LASTNAME
    SQL> Edited by: AP on Aug 10, 2010 3:45 AM

  • String to Vector

    I have a vector of form
    Vector[[string1,string2][string3,string5]]
    How can i convert it to Vector of Vectors , meaning [string1,string2] should be converted to a vector and so is the [string3,string5]

    hi praveen75,
    please try this....
       *   private static Vector extractorVectorFromString(String inVectorString)
       *      parameter: a string of the form "[[string1,string2][string3,string5][string7,string7]]"
       *      output: a vector of vectors
      private static Vector getVectorOfVectorFromString(String inVectorString)  {
        String vectorString = inVectorString.trim();
        vectorString = inVectorString.substring(1,inVectorString.length()-1);     // get rid of first '[' and the ']' from string
        Vector v = new Vector();
        int endIndex = 0;
        while (vectorString.length() > 0  && endIndex >= 0) {
            endIndex = vectorString.indexOf("]");
            if(endIndex > 0)  {
              String innerVectorString = vectorString.substring(1,endIndex);
              int i = innerVectorString.indexOf(",");
              Vector innerVector = new Vector();
              innerVector.add(innerVectorString.substring(0,i));
              innerVector.add(innerVectorString.substring(i+1,innerVectorString.length()));
              v.add(innerVector);
              vectorString = vectorString.substring(endIndex + 1,vectorString.length());
        System.out.println("getVectorOfVectorFromString(), v.toString = " + v.toString());
        return v;
      public static void main(String[] args)  {
        String inVectorString = "[[string1,string2][string3,string5][string7,string8]]";
        getVectorOfVectorFromString(inVectorString);
    }Hope this is what you wanted. It construct a vector of vectors from a string of this form:
    String inVectorString = "[[string1,string2][string3,string5][string7,string8]]";

Maybe you are looking for

  • Performance Improvements in Report

    Dear ABAPers,      I am developing the Report.The Input parameters are Brand name , Month and Year.The data has to be selected from header tables , item tables and Sub item tables.So i am writing the select statement inside the loop because i could n

  • My macbook pro is going slow lately

    My macbook pro is going slow lately, it takes longer time to just open a finder window or a simple photo or word document or pdf document. Everything in general goes slower than before. I don´t know what to do to fix this and have the macbook pro run

  • PDF file created from Oracle Report is attached wrongly

    Hi, Please help. It is very urgent. I am using Oracle Developer 10gR2, Oracle Report 10.1.2 on Windows 2000. I would like to attach the PDF file created by Oracle Report to the Notification sent from Workflow. I use the following package procedure in

  • My 6310 All in One will print a test page but will not print from Publisher, Notepad, etc. WTH?

    My HP 6310 will print a test page fine, but will not print from Publisher, Notepad, etc. It goes thru the motions, but the image printed is almost not there. I have new ink cartridges in it. I have adjusted the print settings. STILL won't print prope

  • Adding East Asian Language Pack

    [I stupidly posted this in the Bold forum.  Reposting here, where this topic obviously belongs.] Hi, all, I've read the BlackBerry KB on how to install the East Asian Language packs on my BlackBerry.  But I am still confused.  The directions say: Ope