Shorting My String Words in Alpabetic Order

Hi,
pls give me some hints.
to print the words in my string in Alpabetic order..
public static void main(String args[]) {
String myString ="this is my text to be shorted in alpabetical order"; // assigning you String
          //Comparetor c = new Comparetor();
     SortedSet tset = new TreeSet( );
                    tset.add(myString);
                    Iterator it =tset.iterator();
                    while(it.hasNext()){
                         String outString =it.next().toString();
                         outString.split("");
                         System.out.println(outString);          
Thanks

import java.util.*;
public class Srini_test {
      * @param args
     public static void main(String args[])
          String arr ="gat edoC siht htiw od ot gnihton sah gnimmargorp avaJ sA, tamrof txt nialp ni nettirw s'ti fi neve  edoc crs  dnatsrednu ot uoy tcepxe I , remmargorp  avaj a gnieB .sgat edoc esu ot woh em gniwohs rof sknahT ekruB.lyrraD raeD";
          for(int j= arr.length()-1;j>=0;j--)
               System.out.print( arr.charAt(j));
          System.out.println(" ");
          String myString ="this is my text to be shorted in alpabetical order"; // assigning you String
          String []word =myString.split(" ");
          SortedSet<String> tset = new TreeSet<String>( );
               for (int i=0;i<word.length;i++)
                    tset.add(word);
          Iterator it =tset.iterator();
               while(it.hasNext())
                    String outString =(String)it.next();
                    System.out.print(outString +" ");
Hope it will go in your Head now                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • If we can increase the length of the Short Text field in a purchase order?

    Hi Experts,
    Please suggest if we can increase the length of the Short Text field in a purchase order?
    If yes, How? and what will be the impact?
    Thanks
    Gavar

    Dear Arpit,
    You can use PO Text field for long description of the material.
    Regards,
    Manish Jain

  • How do i convert a pdf file to a word doc in order to make changes

    How do I convert a pdf file into a word doc in order to make chnages?

    You need Acrobat and can then use File --> Save As... --> Microsoft Word. Just don't expect miracels. PDFs aren't meant for editing and you may end up with clumps of text and lose all formatting and may have to rebuild the document completely.
    Mylenium

  • Short to String

    Hello, I was trying to do a short to String format... Using Hex numbers
    Lets pretend first is FF, second is F4, third is 22, and fourth is C9 in the splitUpString array....
    short first = Short.parseShort(splitUpString[0], 16);
    short second = Short.parseShort(splitUpString[1], 16);
    short third = Short.parseShort(splitUpString[2], 16);
    short fourth = Short.parseShort(splitUpString[3], 16);
    lastip = first.toString() + second.toString() + third.toString() + fourth.toString(); //WRONGI just want to combine them, but I do not know how.. It is for IPs.. Any help? Thank you!

    Lets say the first,second,third,and fourth hex
    numbers are FF FF FF FF, it would give you 255 255
    255 255.So, you start with the four Strings "FF" "FF" "FF" and "FF" and you want to end up with a single String "255 255 255 255"? If that's the case, and you've already got the ints, then: String result = int1 + " " + int2 + " " + int3 + " " + int4;

  • Printing Numbers In Words In Purchase Order

    Dear Friends,
    I want to display the total Purchase Order value in words eg- 300.00 as Three Hundred Only, Plz tell me how to do this. Also please tell me from where I will get the Terms & conditions field for PO, I have searched EKKO & EKPO but there is only Terms Key not the Terms & conditions.
    Bye,
    Nishant

    You can use the function module  
    report zrich_0002 .
    tables spell.
    data : t_spell like spell occurs 0 with header line.
    data : pamount like spell-number  value '1234510'.
    sy-title = 'SPELLING NUMBER'.
    perform spell_amount using pamount 'USD'.
    write: 'NUMBERS', t_spell-word, 'DECIMALS ', t_spell-decword.
    *       FORM SPELL_AMOUNT                                             *
    form spell_amount using pwrbtr pwaers.
      call function 'SPELL_AMOUNT'
           exporting
                amount    = pamount
                currency  = pwaers
                filler    = space
                language  = 'E'
           importing
                in_words  = t_spell
           exceptions
                not_found = 1
                too_large = 2
                others    = 3.
    endform.                               " SPELL_AMOUNT
    please reward points for helpful answers and mark post as solved if your problem is solved.  Thanks
    Regards,
    RIch Heilman

  • Substitution String in Row Template order dependant

    Hi Folks,
    This questions is related to an earlier Complex Detail Report Layout: Can it be done? about building a complex row template (thanks for your help, Vikas!).<br><br>
    Having built the row template (Named Columns) and tested it in a separate application, I have been preparing to incorporate it into the target application. (Here's a screen shot of the work in progress.) I decided to see if I could use column aliases with the substitution strings and so added an alias to the query for the report.<br><br>
    Strange values appeared (like a "Y" for a Project Name) and initially I thought the aliases wouldn't work, so I backed the change out. However, it was now quite apparent that the substitution strings were not taking their values from the column names, as I expected. I was able to put the values in the correct place by modifying the order of the columns selected in the query.<br><br>
    Am I misunderstanding? Shouldn't the order of the columns in the select statement be irrelevant when named columns are used? <br><br>
    Since the order in the query is NOT the order displayed in the template, and I have nearly 30 fields, (many of which are dates, and I couldn't possible guess which is which if the substitution doesn't work properly), it seems important to understand how to ensure the proper values appear in the report.<br><br>
    Many thanks for your help,<br><br>
    Petie

    I take it back. This is whacked. Please take a look at the picture (http://tinypic.com/view/?pic=nygyu0)
    OK, I had a select statement:
    select ps.project_name, ps.project_manager,  ps.gts_dependant, ps.gxp_relevant from project_status ps, eprs_program p
    where
    ps.program_id = p.id and
    p.program_number = :P6_PROGRAM_NUMBERThis populated the fields #PROJECT_NAME#, #PROJECT_MANAGER#, etc. properly.
    I even switched the order around and put the ps.project_manager ahead of the ps.project_name and template still worked.
    I restored the order and checked again. All is good.
    I changed the query and added an alias like so:
    select ps.project_name as "PROJ_NAME", ps.project_manager,  ps.gts_dependant, ps.gxp_relevant from ...The report showed the substitution string "#PROJECT_NAME#" (as expected, because the column was now aliased.) So this is good.
    I went to the row template definition and changed the substitution string #PROJECT_NAME# to #PROJ_NAME# to match the query -- and the substitution strings broke again!
    The report template now behaves as described earlier; being position dependant. Now I suspect that this is a bug, and not something caused by my mucking around.
    I would greatly appreciate your thoughts on the matter and potential workaround. At this point, I will likely delete the region and try creating a new region. I would hate to loose the whole page, the top part was a lot of effort. <sigh>
    Thanks,
    Petie

  • Wrong Conversion of Amount in Words in Purchase Order print out

    Hi,
    Please help me with the problem in printing of Purchase Order, there is an error in amount in words. For example the total amount in numbers is 93,311.30 however the amount in words will be nine million three hundred  thirty-one thousand one hundred thirty.As per my understanding the amount in number was multiply by 100. Please help what i should check.
    Thanks,
    Richard

    Dear,
    Take the help of the ABAPER guy and check what he written in the program of the PO layout & printout.
    http://help.sap.com/printdocu/core/print46c/en/data/pdf/BCSRVSCRSF/BCSRVSCRSF.pdf
    This will solve your problem
    Thanks & regards.
    Varun Bisaria
    Edited by: Varun Bisaria on Oct 21, 2011 2:10 PM

  • Sorting a String Array in alpha order (Using ArrayList)

    Hello all!
    I am pretty new to Java and am trying to do a, seemingly, simple task; but cannot get the syntax right. I am trying to sort an ArrayList in aplha order based off of the variable String Product. Any help would be awesome!
    First Class:
    //This program stores all of the variables for use in Inventory.java
    public class Vars {
         // defining all variables
         private String product;
         private String prodCode;
         private double price;
         private double invCount;
         // Begin listing getters for class
         public Vars(String product) {
              this.product = product;
         public String getProdCode() {
              return prodCode;
         public String getProduct() {
              return product;
         public double getPrice() {
              return price;
         public double getInvCount() {
              return invCount;
         // Declaring the total variable
         public double total() {
              return invCount * price;
         // Begin listing setters for variables
         public void setProduct(String product) {
              this.product = product;
         public void setProdCode(String prodCode) {
              this.prodCode = prodCode;
         public void setInvCount(double invCount) {
              this.invCount = invCount;
         public void setPrice(double price) {
              this.price = price;
    Second Class:
    //This program will use the variables stored in Vars.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Scanner;
    public class Inventory {
         public static void main(String args[]) {
              Scanner input = new Scanner(System.in);
              //defining and declaring local variables
              String exit;
              int counter;
              double gtotal;
              exit = "exit";
              counter = 0;
              gtotal = 0;
              //beginning message and beginning of the loop
              System.out.print("Welcome to the Inventory Contol System\nPlease enter the Product name: ");
              System.out.println();
              System.out.println("When finished entering in the data, please enter EXIT in place of Product name.");
              String name = input.next();
              List<Vars> var = new ArrayList<Vars>(); //creating arraylist object
              //loop while exit is not entered, exit loop once exit is typed into product variable
              while (name.compareToIgnoreCase(exit) != 0) {
                   Vars vars = new Vars(name); //calling Vars methods
                   counter = counter ++;
                   System.out.println("Please enter the Product Code: ");
                   vars.setProdCode(input.next());
                   System.out.println("Inventory Count: ");
                   vars.setInvCount(input.nextDouble());
                   //Making sure that the value entered is a positive one
                   if(vars.getInvCount() < 0){
                        System.out.println("Please enter a positive number: ");
                        vars.setInvCount(input.nextDouble());
                   System.out.println("Price per product:");
                   vars.setPrice(input.nextDouble());
                   //Making sure that the value entered is a positive one
                   if(vars.getPrice() < 0) {
                        System.out.println("Please enter a positive number: ");
                        vars.setPrice(input.nextDouble());
                   System.out.println("Please enter the next Product name, or enter EXIT: ");
                   name = input.next();
                   gtotal += vars.total(); //calculation for Grand Total of all products entered
                   var.add(vars);
                   static void slectionSort(int[] product) {
                   for (int lastPlace = product.length-1; lastPlace > 0; lastPlace--) {
                   int maxLoc = 0;
                   for (int j = 1; j <= lastPlace; j++) {
                   if (product[j] > product[maxLoc]) {
                   maxLoc = j;
                   int temp = product[maxLoc];
                   product[maxLoc] = product[lastPlace];
                   product[lastPlace] = temp;
              //Sorting loop function will go here, before the information is displayed
              //Exit message and array list headers
              System.out.print("Thank you for using the Inventory program.\nHave a wonderful day.\n");
              System.out.printf("Code\tProduct\tCount\tPrice\tTotal\n");
              System.out.println();
              //For loop to display all entries via an ArrayList
              for (Vars vars : var) {
                   System.out.printf("%5s\t%5s\t%.01f\t$%.02f\t$%.02f\n\n", vars.getProdCode(),
                             vars.getProduct(), vars.getInvCount(), vars.getPrice(),vars.total());
              //Displays the amount of entries made and Grand Total of all products entered
              System.out.println();
              System.out.printf("The number of products entered is %d\n", var.size());
              System.out.printf("The Grand Total cost for the products entered is $ %s\n", gtotal);
              System.out.println();
    }

    go through below links, you can easily understand how to sort lists.
    http://www.onjava.com/lpt/a/3286
    http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html
    http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

  • Parsing a string in a given order

    Hi All,
    I want to parse a string and rank it in a given order.
    Eg : i have a string as 'A | B | C | D'. I would like to parse this string and give a rank in order.
    It should appear as below.
    Parsed string order
    D 1
    C 2
    B 3
    A 4
    Any help is greatly appreciated..

    A database version would help us providing you with a relevant solution.
    Starting with 10g, you can do :
    SQL> var my_str varchar2(30)
    SQL> exec :my_str := 'A|B|C|D'
    PL/SQL procedure successfully completed
    SQL> select item
      2       , row_number() over(order by item desc) as rank
      3  from (
      4    select regexp_substr(:my_str,'[^|]+',1,level) as item
      5    from dual
      6    connect by level <= length(regexp_replace(:my_str,'[^|]+')) + 1
      7  );
    ITEM                    RANK
    D                          1
    C                          2
    B                          3
    A                          4
    In 11.2 :
    SQL> select *
      2  from xmltable(
      3       'for $i in ora:tokenize($str,"\|") order by $i descending return $i'
      4       passing 'A|B|C|D' as "str"
      5       columns item varchar2(10) path '.'
      6             , rank for ordinality
      7       )
      8  ;
    ITEM             RANK
    D                   1
    C                   2
    B                   3
    A                   4
    Edited by: odie_63 on 11 janv. 2012 12:56 - added 11.2

  • All words in reverse order - "mirror" effect

    I have got N80 phone. Just upgraded to a new firmware from Nokia website via USB cable. Installation went perfect, no any failures or error. At the end i got all words in the phone in reverse order, actually with "mirror" effect.
    The phone is working OK, i.e. i can call, receive calls etc. But all words and numbers in reverse ("mirror").
    Please help. Does anybody have ideas?

    As Korngear says - re-install as you have nothing to loose. However there are 1-2 postings in the forum about this happening on other phones. No real solutions offered there tho'.

  • Regular expressions: the shorter the string, the longer the time to analyse

    Hello there !
    I've got a problem with regular expressions...
    I analyse those two strings with the same regular expression, searching for the "message" word.
    The first of them, which is much longer than the other one, is instantly analysed... but the second one takes about to one second !
    Do you see the problem ? (I do not, as you can guess...).
    I tried to put the same special characters in the two ones... but it still works slowly for the second one.
    This is instantly analysed:
    "Coucou----- Origin.a.l. .message -----From: clems= To: Cl�ment S=ent: Wednes=day, April 30, 2003 1:38 PMSubject: Fw: mail de test----- Original Message -----From: clemsTo: Cl�ment Sent: Wednesday, April 30, 2003 1:37 PMSubject: mail de testcoucou, ceci est un mail de t.e.s.t... !!!Clems.".matches("((.*\\W)*\\Q" + "message" + "\\E(\\W.*)*)")
    This takes about to one second:
    "This is a b message ubodyub.brHere s a href= http:www.tano.fr.fm the second linea.".matches("((.*\\W)*\\Q" + crit�reActuel.getLeMot(i).toLowerCase() + "\\E(\\W.*)*)")
    Pleaaase, help ;)
    Clement

    Well in fact everything seems to work... there was another problem...
    My regular expression seems to be wrong and the code too...
    I apologize... sorry for the waste of time.
    See you later :) for my next wrong problem ! :))
    Clement

  • Change PR item short text when created from Work Order

    Hello,
    Is there a way to edit the PR item short text when the PR is generated from a Work Order. When we open the PR, the item short text is grayed out.
    We have created Material Master Number for Contract/ BPA items. When we input that particular material number under the components tab on the WO then release it ,it creates a PR. The Material Master description gets transfered to the PR.
    Our issue is that the Material Master is to generic and we would like to change the description on the PR level.
    Is this possible?
    Thanks,

    Hi
    I think neither there is any way to change the Material Description in PR nor its a good SAP Practise as it is having lot of implecations of stocking , physical inventory , reconciliation etc .
    If Item codes are generic suggest if u can use the PR or PO long text to enable the buyer for the procurement & supplier for supply the material as per long text specifications .
    Regards
    Sameer

  • How do I shorten one region and take up slack keeping later regions intact and in synch in short story spoken word reading

    I import one track which is one region and it is a little more than one hour long. It is the import from the master, It is a spoken word short story and the reader makes a a few flubs/miscues in reading. He repeats to redo text where he makes reading mistakes. So, I have a story in one track-spoken word. Now, I edit out mistakes and finish the first draft.
    There are now 100 regions in the track. I go back to fine tune the edit and recheck for reading mistakes and editing mistakes. In region 10 I realize I must cut a portion out because of an extraneous word mishap. This spilt makes region 10 shorter. Now I must move ALL regions, 11-100, up to take up the unwanted gap. How do I get all, 11-100 regions to move up and keep the story intact, in synch?
    Then, in region 20 I realize I must lengthen it, part of a sentence is cut off. I re-import the original to a new track and find the sentence I need and spilt the track so I can replace the faulty region 20 with the new and longer region 20. Now, region 21-100 need to move downstream to make room for the longer replacement region.
    How do I get 21-100 to move as one unit, downstream so I can add 20 and keep everything in sync?
    I do not think, or at least hope, I have to select each 21-100 regions individually.

    jackerle wrote:
    How do I get all, 11-100 regions to move up and keep the story intact, in synch?
    the most obvious way is to zoom out and drag select them all.
    a less obvious way would be select all the regions (click in the track header) and choose the Join menuItem to create one large region out of all the peices, then you're moving only a sngle region after your edit point
    jackerle wrote:
    Then, in region 20 I realize I must lengthen it, part of a sentence is cut off. I re-import the original to a new track
    you created extra work for yourself, edits are non-destructive:
    http://www.bulletsandbones.com/GB/GBFAQ.html#nondestructive
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    just grab the bottom right corner of the region and drag to the right to bring back the missing section

  • Short wrapper , String

    This is a very easy question i suppose...
    what's used for "Short wrapper" and what about its sintaxis??
    and what about String?
    thank you so much!

    A short is a primitive: it's just a number, not an Object. See also: int, double, char, boolean
    A Short is an Object that contains a short. That's called a wrapper class, and it gives you functionality that you wouldn't find using primitives alone. See also: Integer, Double, Boolean
    A String is also an Object that represents some text.
    All of the Objects (including the wrappers) are in the API. You can find a bunch of information on primitives just by googling "java primitives".
    Hope this helped!

  • Almost half a million ArrayList String words too much?

    I put together a ~400,000 word list for my password generating program. It has 3 modes which choose words from this list, and I fear that the program will lag or be slow to load. Do I need to add some extra efficiency lines of code to keep it snappy? Here is what I'm doing so far:
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.List;
    public class WordData {
        public List<String> wordList;
            wordList = new ArrayList<String>();
            wordList.add("cat");
            wordList.add("dog");
            wordList.add("bird");
            //blah blah
    }I am coding all of the words into a separate class in the program to keep the list of words out of reach of people looking to add to their brute force lists. NetBeans has a macro recorder so I will let it run overnight while it puts each word within proper syntax. Am I overloading the wordList? It having to add each one of the words I specified would take a while, I think. Accessing it from a file makes no difference either. The current text file is about 4MB.

    I put together a ~400,000 word list for my password
    generating program. It has 3 modes which choose words
    from this list, and I fear that the program will lag
    or be slow to load. Do I need to add some extra
    efficiency lines of code to keep it snappy? That's for you to decide. When you run it, does it run fast enough for your requirements?
    If you're using this in the sense of "if the word list contains the password, then bad password," then a Set's contains method will be faster than a List's.
    I am coding all of the words into a separate class in
    the program to keep the list of words out of reach of
    people looking to add to their brute force lists.Huh?
    If I'm running this program on my computer, or writing code that uses that class, then I can see all the words that are there.
    Am I overloading the wordList? What do you mean?
    It having to
    add each one of the words I specified would take a
    while, I think. Accessing it from a file makes no
    difference either. The current text file is about 4MB.Reading a 4MB file to build a 400k entry list or set should be pretty quick, but the only way you'll know if it's fast enough for you is to try it.
    However, I would NOT put 400,000 string constants into my .java file. I'm pretty sure it won't even compile if you do. DEFINITELY load those words from a file, or store them in a DB and use a SQL query to see if the user's password is present in the DB.

Maybe you are looking for

  • How can I prevent an e-mail address being underlined as a link?

    I am using Pages to create a document to be printed by newspapers and magazines. When I put in my e-mail address Pages automatically underlines it as a hyperlink to open an e-mail message. A link will be useless in a printed document. But I don't wan

  • Value of the start in the Select with in a Hierarchical Query

    Exist any way for put in the select the value of the start with in a Hierarchical Query? An example: I'll need sth like CTH@> select n code, level, np code_parent, 1 code_first_parent 2 from demo 3 start with n=1 4 connect by np = prior n 5 ; CODE LE

  • System slow down - help!

    I don't think I'v ever had this problem before - the whole system keeps slowing down to a crawl - every app, the cursor, every thing - I just did the disk utility maintenance yesterday (from the Repair partitioin), cleaning permissions & verifying /

  • Acrobat 8 Standard download available?

    I purchased a download for Acrobat 8 Standard a while back,and just lost it in a computer crash. I see that I could download Acrobat 8 Professional. Is there any way of getting my Acrobat 8 Standard download back?

  • Three buttons in a form

    Hi, I have three buttons in a form. Each button passes control to a different servlet when clicked. The problem is it is not passing any parameters when button is clicked. When i used the buttons individually everything works fine, the parameters are