Question on printing out repetive numbers/letters in toString()

i was doing my lab and this one was one of the labs we skipped but im still curious as to how to do it. it was basically about printing out any primative type in the toString but canceling out repetitive letters/numbers.
ex: String c = "cccccccfebq";
then the print out when i call toString will only be febq. any suggestions as to how i can do this.
thanks in advance!

http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/package-summary.html
Regular expressions...I can't think of a good way to describe what they do....
It's a way you can manipulate strings (for searching or replacing) using rules which can be simple or complicated or somewhere in between. The rules are like a little language of their own. In particular a grammar is defined in which sequences of characters can be thought of as generated by these rules and so the searching and replacing is done with respect to how the generated sequences compare against the input string.
God that's a lousy description. I'll bet jschell or UlrikaJ can do better.
In the meantime read the docs. There may be a tutorial online but I'm too lazy to search for it for you.
BTW I got that ("aaaaaaaaaaaaWXYZ") from your first example. The question is what happens if there are non-sequential repetitions.

Similar Messages

  • Print out some numbers

    Hello:
    At the movement I got array nums[]={"1", "2", "3", "4", "5", "6", "7", "8"},
    Please tell me how to print out some numbers from the array by using for loop, and the result exactly like System.out.println( " 1 2 3 4 "); System.out.println(" 5 6 7 8);
    Please run my codeing first, I'd like the result exactly same as my coding showing.
    Thanks
    import java.awt.*;
    public class Test{
    private static Test t;
    private static String nums[]={"1", "2", "3", "4", "5", "6", "7","8"};
    public static void main(String [] args){
         t=new Test();
    private Test(){
         print();
    private void print(){
         System.out.println(" 1 2 3 4 ");
         System.out.println(" 5 6 7 8 ");
    }

    Ugh!
    I didn't see that you wanted 1,2,3,4 and 5,6,7,8 on new lines. This will do the trick. It's ugly but it works.
    public class Test
        private static Test t;
        private static String nums[] = {"1", "2", "3", "4", "5", "6", "7", "8"};
        public static void main( String[] args )
            new Test();
        private Test()
            print();
        private void print()
            for (int i = 0; i < nums.length; i++) {
                if (i == 4) {
                    // Print a Blank Line
                    System.out.println("");
                String num = nums;
    System.out.print(num + " ");
    cheers,
    Greg

  • HT2736 How do I find out what numbers & letters were scratched off of my iTunes Gift Card by mistake?

    How do I find out what numbers & letters were scratched off of my iTunes Gift Card by mistake?

    iTunes Store:  Invalid, Inactive, or Illegible codes - http://support.apple.com/kb/TS1292 - gift cards

  • When printing out a hard paper copy of your itunes library

    Greetings Everyone...
    I've just finished the herculean task of adding all my CD's into my ipod (29,637 store-bought discs and a smattering of vinyl LP's and singles...and still have 6gb left!). The artwork has also been entered, but I have a question:
    When printing out a hard paper copy list of your itunes library, the only artwork that appears alongside the title/songs is the first image. What if there is more than one image per LP/CD? Is there a way to manipulate the choices show all images appear on the page for each album? Some artwork is just too rare not to be able to view everything. Please advise, and thanks in advance.

    Hi boglegod,
    Welcome to the Support Communities!
    It sounds like you need to unistall the 32 bit version of iTunes and install the 64 bit version on your Windows computer.  Do you have a backup of your iTunes library?  Do you have any other security software installed besides Norton?  The following articles may help you with this:
    I would suggest following the information in the "External drive" section of the article below:
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/HT4527
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    http://support.apple.com/kb/ht1923
    I hope this information helps ....
    Have a great day!
    - Judy

  • How to print batch numbers on the AR invoice print out

    Hi Gurus;
    Here is my question; I need to be able to print batch numbers on the print out of AR invoices, I used variable 492 in PLD and I am able to see the batch numbers directly linked with the AR invoice, meaning that I wont be able to see batch numbers that I entered on the Delivery even is the delivery doc was copy to the AR invoice.
    Is there anyway that I can see the batch numbers on the AR invoice print if I entered the batch number on the delivery and then copied that delivery to an invoice??
    My client wants to be able to send their customers and invoice with a batch number but he always follow the process from sales order to delivery and delivery to AR invoice and what this means is that he always entered the batch numbers on the delivery documents.
    Please help me!!!
    Thanks
    Jenny

    If the ad hoc printer mode is not available for the envy, there are some reasonably cheap ways to get a wifi network in your car.   A cheap router from best but will generate the wifi network.  Does not matter if you have Internet or not.  A ifi device will also work, and most/ all of them run on batteries.  Lastly, if you have a smart phone or I phone that generates a wifi hotspot, that may be enough to support the printing function.  ( I need to test my I phone later today to see if that works.)

  • PrintWriter question- is it possible to print out a table?

    Hi everyone,
    I am taking the information retrieved from a database and printing it out to a text file using FileOutputStream and PrintWriter. My question is can i format the printout in any way-- like print out certain records in some sort of table, or make some text bold.
    I don't know if the code is relevant, so i paraphrased it here:
    FileOutputStream fos = new FileOutputStream(x);
    PrintWriter w = new PrintWriter(new OutputStreamWriter(fos));
    <here i connect to database>
    <a couple of w.print() statements and w.println() statements>     
    w.close();

    You can print data to a file in any form you want. The catch is, as far as i know, you have to lay it out manually. You must convert the data to strings and use white space to lay it out how you want it to look in the text file. Looking over some text I think you would use BufferedWriter to write strings to a file. I don't know any short and easy way, maybe some of the more experienced people will help.
    Check the java API on file i/o start at file and work down and see what classes do what you want them to do. If the file is online check the java.net stuff.
    If you are trying to print a table to a printer an easy way to do that is make the table in an applet, then print the applet from explorer or netscape.

  • Would like a participant to answer essay questions with capacity to print out, but not be visible for next participant.

    As the title says, I would like the participants to answer open, reflective questions and then be able to print answers.  Alternatively, each participant would have their own version of the course with all their questions answered which they could return to with a password.  Ideas?

    I'm thinking of using the Notes function as the responses need only to
    be seen and saved by the participant not by some offline teacher.  I'm
    also going to explore the Short Answer to see exactly how short it must
    be.  Finally, if all else fails, I might be able to attach a doc or pdf
    file to the course which each person could upload and enter text into,
    save, and later print out.
    Thanks for the info about LMS.  That is more expensive than my client
    wants to go.
    J.D.

  • Outline Print out for bullets & numbering

    Hi,
    In RoboHelp my default bullets have a left margin of say "0",
    but when I generate the print version they have a margin of say
    "1". It looks like this:
    1. xyz
    * xyz
    SSL Print out
    1. xyz
    * xyz
    Any ideas for a permanent fix?

    For anyone else the answer is:
    The margin settings for the numbered list can be tweaked by
    editiing the Lists style in RH (Format > Styles > Lists >
    Modify > Format > Paragraph >Indentation).
    If you don't see "Lists" as a style, make sure the box (Hide
    Inherited Styles), below the available styles is not checked, then
    it should show up.

  • In Numbers '09, version 2.3 (554), how to I get spreadsheet gridlines to print out? I have a Macbook Pro and use OSX 10.9.4 Mavericks.

    In Numbers '09, version 2.3 (554), how to I get spreadsheet gridlines to print out? I have a Macbook Pro and use OSX 10.9.4 Mavericks.

    HP,
    In Numbers '09, the only lines that print are Cell Borders. Apply borders and test by Printing to PDF.
    Jerry

  • How Do You Print Out A List Of Skype To Go Numbers ?

    When I attempt to print out a list of my Skype To Go numbers only the left hand column prints.  This is the column that contains the name and actual phone number.  The right column that contains the Skye To Go Number does not print.  How do I print both columns?Thank you, Melissa

    Hello, Melissa, and welcome to the Skype Community!
    Did you use the link from the page where you can see all the numbers?If you did and it still didn't come out exactly the way you wanted it, try it again with a different browser or with javascript enabled. For me, it printed what needed to be printed without an issue.
    If you're still having issues, please respond here and we'll see what else can be done.
    For your reference, this is how mine came out:
    Click to Enlarge

  • Pages are not printing out correctly. I have tried to fix in the options, with no luck. It prints out with spaces in between the letters.

    When I go to print any page from an email, webpage, pdf file..the pages print out very wide fonts to the point where it is unreadable. I have tried to fix in the options with no luck. I can provide you with visuals if you need me to.

    Thanks very much! It works! The print / review print - print works like it is supposed to. The print is corrected and works great. Thanks again.

  • Questions on printing

    1) How can I suppress/hide the column letters and row numbers when printing a Numbers spreadsheet? I have a Numbers spreadsheet that I would like to print out, but I don't want each column and row showing its letter or number, respectively, in the printout. (I've just noted that in the spreadsheet printout I just made the letters and numbers do not appear. Is this the default/standard behavior, or can it be turned off and on?)
    2) How do I set the print area? I just printed out a spreadsheet with two columns each less than two inches wide and eleven single-line rows, and it printed out onto four pages.
    3) How do I hide the grid lines during printing?
    4) How do I vertically and/or horizontally center a table on the printed page?

    1. The numbers and letters are temporary, they only appear when a cell is selected to type in.
    They never show in a printed page or a pdf.
    2. Print view is there to check just what will be printed on each page, you can use the slider at the bottom to make the tables bigger or smaller to fit. Delete any columns and rows not required. You can make any changes you want to in print view.
    3. Click on the table on the sidebar to select as a graphic, set inspector > table > cell borders to None. They will show as faint line when you are working on the table but do not show when printed or when not selected to work on. Same as the row numbers etc.
    4. Delete all rows and columns not required and drag the table to the middle of the page in print view.
    Hope that helps a bit.

  • Why would my PDF Form print out the tab order on top of my form fields?

    When this user prints out the filled out PDF form we created, it prints the tab order as a little square numbered box right on top of the form field entry.  The tab order prints over all types of fields, text entry fields, check box fields, etc.
    I am not sure if this issue is related to someone using a non-Adobe PDF reader, or an issue with their printer?   Unfortunately, we cannot duplicate this issue ourselves and are hesitant to interrogate our client futher on the matter. 
    Has anybody else ever seen this type of print out from a PDF form issue?

    Thanks for your reply!  Based on your suggestion I did a little experimenting.
    This is a form saved to Enable User Rights so PDF viewers can fill out and email or save the form.   After seeing your question, I opened the form for editing (actually saving a copy first that was not restricted, and editing the copy).  I then toggled the Tab Numbers on via Tools > under the Forms header I clicked Edit > Other Tasks > Edit Fields > Show Tab Numbers.  After revealing the tab numbers I then tried to save the form as a Reader Extended PDF, but the Enable Additional Features option was grayed out.  Even if I wanted to, I could not save the form with the tab numbers revealed.
    The form itself was also received by our company electronically and when viewed does not show the tab number order and when we print it, it prints as expected (no tab order numbers).
    We are suspecting that this may be an issue either with the end users printer? Or possibly viewing and printing via an alternate viewer like Foxit?
    Anybody run across this odd behavior?

  • This is about recursion and the print out

    Please give me a "HINT" on how to;
    1- Control the way I print the file out, like instead of printing "A, B, C, D, E, F", printthe alphabets in two lines of three alphabets, like;
    "A, B, C"
    "D, E, F"
    2- A hint on writing a recursion method so I can print out from more than one inFile.
    This is what I have so far.import Alphabets;
    import java.util.StringTokenizer;
    import java.io.*;
    public class PrintAlphabets
       public static void main (String[] args) throws IOException
         int n= 100;
          Alphabets[] letters= new Alphabets[n];   //array of numbers
          StringTokenizer tokenizer;
          String line, name;
          String units;     //number of Alphabets available in the file.
              int count = 0;
          String fileout = "c:\\Alpha.txt";
         File file = new File(args[0]);
          FileWriter fw = new FileWriter (fileout);
          BufferedWriter bw = new BufferedWriter (fw);
          PrintWriter outFile = new PrintWriter (bw);
          try
               FileReader fr = new FileReader (file);
               BufferedReader inFile = new BufferedReader (fr);
               line = inFile.readLine();
               while (line != null)
                   tokenizer = new StringTokenizer (line);
                     while (tokenizer.hasMoreTokens())
                       try
                          units = tokenizer.nextToken();
                           if ( units.equals("#include") )
                              tokenizer.nextToken();
                           else
                          letters[count++] = new Alphabets (units);
                       catch (Exception e)
                          System.out.println ("Error in input. Line ignored:");
                          System.out.println (line);
                 line = inFile.readLine();
             inFile.close();
              for (int scan = 0; scan < count; scan++)
                            outFile.print (letters[scan] + " " );
          catch (FileNotFoundException exception)
             System.out.println ("The file " + file + " was not found.");
          catch (IOException exception)
            System.out.println (exception);
                System.exit(0);
               outFile.close();

    I thought I send you te whole code again because I still get the "null" thing.
    import Alphabets;
    import java.util.StringTokenizer;
    import java.io.*;
    public class PrintAlphabets
       public static void main (String[] args) throws IOException
         int n= 100;
          Alphabets[] letters= new Alphabets[n]; ;  //array of numbers
          StringTokenizer tokenizer;
          String line, name;
          String units;    
              int count = 0, printCount=0, scan=0;
          String fileout = "c:\\AlphaResult.txt";
         File file = new File(args[0]);
          FileWriter fw = new FileWriter (fileout);
          BufferedWriter bw = new BufferedWriter (fw);
          PrintWriter outFile = new PrintWriter (bw);
          try
               FileReader fr = new FileReader (file);
               BufferedReader inFile = new BufferedReader (fr);
               line = inFile.readLine();
               while (line != null)
                   tokenizer = new StringTokenizer (line);
                     while (tokenizer.hasMoreTokens())
                       try
                          units = tokenizer.nextToken();
                           if ( units.equals("#include") )
                              tokenizer.nextToken();
                           else
                          letters[count++] = new Alphabets (units);
                       catch (Exception e)
                          System.out.println ("Error in input. Line ignored:");
                          System.out.println (line);
                 line = inFile.readLine();
             inFile.close();
              for (scan = 0; scan < count; scan++)
                            if (printCount == 3)
                               {   outFile.println(); 
                                    printCount = 0;
                             String newLine = System.getProperty("line.separator");
                             outFile.print(newLine + letters[scan] + " " );
                            printCount++;
                            //System.out.println(letters[scan] + " "  );
                            //outFile.print (letters[scan] + " " );
          catch (FileNotFoundException exception)
             System.out.println ("The file " + file + " was not found.");
          catch (IOException exception)
            System.out.println (exception);
                System.exit(0);
               outFile.close();
    }

  • Printing Document Page Numbers in Pages '09

    Hello again my friends;
    With Peter's help I got my document numbered correctly (with i,ii,iii etc in first section) and (1,2,3 etc in second section).
    Now I can't seem to get them print out on each page, both sets of numbers are located in the footer of each pages respectively.
    Any suggestions?

    Sounds like your printer doesn't print to the edge of the paper and you have the Footer in the non-printing area.
    To test the extent of your printable area, cover the entire page with a box filled with grey and print that.
    Tom solve your footer problem raise it up from the bottom of the page into the printable area.
    Peter

Maybe you are looking for

  • How do I route multiple SB302 switches at different sites and their VLANs?

    Hello Cisco Support Community, First thank you for any replies. The video posted today on 302's and multiple VLAN's on one switch was nice. Thank you, I have that working but it's not really what I need. Though pictures are worth a 1000 words so I ho

  • View Maintenance

    Hello all, In custom table maintenance view I'm using a couple of events in PAI to format records to be inserted.  I also have a program that inserts entries into that table. Is there a function call that I can use instead of regular insert statement

  • Censored Google image search results

    Wanted to sketch a little nude yesterday and happily I opened the Google search in order to get som references. So i entered "nude" in the search field.....but got no hits.... Ehhh, this cant be right, right ? Tried the real Google just to be sure. L

  • MS Word Acrobat icons gone

    After I installed to the latest update to Acrobat Professional 8, the icons from MS Word (Office 2007) disappeared. How do I get them back?

  • Gmail buttons not showing up

    firefox isn't showing navigation and settings buttons on gmail, making it hard to see where things are. The tooltips show up when rolled over with the mouse but all buttons don't show, just outline where they should be. Only site doing this. Already