Longest Run - Sequence of the same character

I want to return the letter that has the longest run in String s. How would i do that.
For example...in "aaabbbbcc"....b would be the result...plz help
Here's my code...but something's wrong with it:
import java.io.*;
import javax.swing.*;
import java.lang.String;
public class StringInfo1 {
public static char longestRun(String s) {
String letter=null;
int num1Letter=0;
int num2Letter=0;
for (int i=0; i != s.length()-1 && s.length() > 0; i++) {
if (s.charAt(i) == s.charAt(i+1)) {
num1Letter=num1Letter+1;
else {
num2Letter=num1Letter;
num1Letter=0;
letter=s.charAt(num1Letter);
return letter(s.charAt(num1Letter));

y doesn't this work

Similar Messages

  • Running steps and sequences at the same time

    Hi,
    I need to run some steps and sequence at the same time in my application due to test time restrictions. I am using Teststand 2.0. Colud you please describe me the methodology.

    Hi,
    Synchronization Step types came in at version 2 and there should be an example in the  \teststand\examples folder.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Get a Report crashed error while running report using the mode character

    Hello,
    I'am getting an "Enable to run report - Report as crashde" issue only when I'am running reports using the mode character. The same report with desformat pdf never has any problems. I have changed the englife (set to one) increase the cachesize but I still have the same issue.
    I'm using report 6i and Oracle 8i.
    Thanks in advance for your help.
    Regards,
    Laurent.

    Hi Thanks for the response,
    In fact the report in character mode is working fine in my environnement but is not working on my customer environnement (which is supposed to be the same as mine). I was thinking of cache size issue or something like this ?
    Regards,
    Laurent.

  • How to make two PCs (one local, one remote) control the same running vi at the same time?

    Hi Labviewers,
    I have a vi running, and two PCs are monitoring it, one is local and another one is remote.
    I can see the remote front panel at the remote machine by using application property node, but it seems only one of the two PCs has the control of the running VI at the same time.
    Is there any way to make the two PCs both have the control of the same vi at the same time?  Switching back and forth the control between two PCs is really annoying.
    Thanks a lot for any help.
    Anne

    What exactly are you trying to control?
    Perhaps another approach? You could use "Shared Variables" from LV 8.0 and have a copy of the writer VI on each of the control PCs edit the value on the host PC. But as soon as I post, someone is going to talk about multiple writers to shared resources being a bad idea.... so just be careful or you may try to edit a value that has already been changed.
    Matt Holt
    Certified LabVIEW Architect

  • Export Limits for Multiple Sequences in the Same Sequence File for TS3.0

    Hi,
    I am using TestStand 3.0 to a test application. Because we want to have our limits in a csv-file I have tried to use the Import/Export tools in TS. But this application only supports to export limits for the selected sequence (e.g. main, or subseq1) at a time. This makes it a pretty hard job to export limits from 30 test sequences. What I need is a possibility to export my limits from �all sequences� in my seq-file.
    I have found an article on NI Dev. Zone about �Export Limits for Multiple Sequences in the Same Sequence File (TestStand 1.0.x)�.
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3D9CB56A4E034080020E74861&p_node=DZ52236&p_submitted=N&p_rank=&p_answer=&p_sourc
    e=External
    I have tried to use this code but because it�s for TS 1.0.2 the limits from my multi num test step and my custom steptypes isn�t exported. So that doesn�t fulfill my needs.
    Is there an updated version with �all sequences� added to TS 3.0? Is there other good solutions to my problem out there?
    Best Regards,
    Morten Pedersen
    CIM Industrial Systems A/S
    Denmark

    Hi David Mc,
    Thanks for your reply. I have already considered this solution because the source code is added in the folder described in your reply. But that is not a good solution. It will cost me a lot of time to establish the toolchain, reverse engineer the source code, make the implementations and build a new dll (most off these is already knowledge by NI). And when NI make future releases of TestStand I have some merge work to do every time NI have made some changes in the files I have changed.
    But as I write above: I have hoped that NI already has/or could made a solution like the one to 1.0.2 (see link in root) to me. And then they could include it in the next version.
    I don't think I am the only one in the TestStand world that ne
    ed this feature.
    Best regards,
    Morten Pedersen
    CIM Industrial Systems A/S
    Denmark

  • Prevent Jobs Running Twice at the same time

    Hi all, I would like to know if they are any ways to prevent a release job to run twice at the same time. For exemple, if  I create a job to run every 5 minutes and the job did not finish after 5 minutes, the scheduler will start the same job agains.  This situation causing us bad issues.
    I double check the job start conditions in sm37 but I found nothing special.
    Thanks for help

    Hi Marc,
    We use a workaround. We have asked our abap developpers to write a small utility report which checks if the job it is part of is already running and aborts the job if it is the case.
    When we need a job which must absolutely run only once at the same time, we just add this utility as first step.
    Regards,
    Olivier

  • Why are all of our devises running off of the same apple I.d .They all have their own account.

    I don't know why three of our devices are running off of the same apple I.d.All three of the devices have there own ids but they are going under the same.Why???

    Because that's the way you set them up. It doesn't happen by itself.
    Odds are you plugged them all into the same computer logged in with the same account, with the same iTunes library, and restored them all from the same backup.
    Don't do that.

  • Is the ipad 1 able to run and download the same apps as the ipad 3

    Is the ipad 1 able to run and download the same apps as the ipad 3

    You have to look at the system requirements for the app. the iPad 1 cannot run a version of iOS higher than 5.1.1. If the app requires a higher veriosn, you cannot run it.
    System reqs for any app in the itunes store are at the left edge of the screen.
    Fortunately most apps still run on the older iOS version

  • Can you have 2 apple tv's running concurrently on the same network

    can you have 2 apple tv's running concurrently on the same network

    Welcome to the Apple Community mafugman.
    Yes, we often have more.

  • Multiple listener running (hanging) on the same port  //weird..

    Hi there,
    today we encountered a strange problem regarding the listener process. (multiple process with the same listener name.. :-( )
    versions: rdbms/listener 10.2.0.2
    OS: AIX 5L 5200-09-04
    so; from the process list of the AIX:
    594032 991330 0 03:43:18 - 0:00 /orabinp/product/ora10g/bin/tnslsnr LSNRprod -inherit
    991330 1 0 Mar 04 - 29:17 /orabinp/product/ora10g/bin/tnslsnr LSNRprod -inherit
    as you see the 2nd listener was initiated from the "original" listener, (the parent ID is 991330)
    the lsnrctl status, stop commands were hanging, the lsnr processes were terminated with -USR2 signal. lsnr start was ok, after this the application was able to connect.
    resolution took around 3 mins, but there is a need to have a root cause analysis. usually when you want to start an already running listener,it results in a "TNS-01106: Listener using listener name 'LISTENERname' has already been started".
    during this double operation there were no connection available (it is clear from listener.log)
    Anyone had this issue?
    Any comments welcome and highly appreciated.
    p.s.
    (oracle version 10.2.0.2 - first question -is it a known bug?- I have not found it in a bug list.. the db will be patched/migrated to 10.2.0.3 at next available downtime)

    Virtual PC can do it, but it's not free. I think VMware as well, but likely not free. Actually, it seems you can evaluate VMware:
    http://www.vmware.com/download/

  • Maximum number of client that possible to running OSD at the same time?

    How maximum number of client that possible to perform OS deployment from SCCM 2012 R2 at the same time?
    Regards, Bar Waelah

    It depends on your infrastructure and design. 
    My DP servers got mirrored mechanical disks and a Gbit nic. We like to run about 10 clients every 2 hours from them. That is enough time to apply our custom image, apply any extra appps and patches. 
    Since we got one of those servers on about 100 locations it means that in the best case I can deploy about 1000 systems every two hours. 
    That's my technical limit BUT that's not the real limit.
    More important is how many users with newly installed systems can your organization handle. There will always be some machines that fails and needs to be fixed (how many non productive users can you have at the same time?). Some users will call hellpdesk
    regardless of instructions, onscreen information, user training and so on. How many calls can your helpdesk handle? There will be requests for extra apps, changed screen resolution, left handed mice settings and so on, maybe printer configs? Same thing here
    - how many of these cases can your support handle?
    Those are the "soft" limiting factors and so far (been doing this for about 15 years now) the "soft" limits have always been lower than the technical limit

  • Multiple running queries at the same time

    Hi!
    I looked around (and RTM) for this but didn't find anything, so I'm asking here.
    I have quite a few long running queries (data loading and such things, warehousing stuff), and I need to be able to run multiple queries/statements at the same time. In TOAD I can do this, start a procedure and while it is running I can do SQL statements in another session tab (it supports threaded sessions - it starts queries in their own background thread/session).
    When I start a long running procedure or query in SQL Developer I can not do anything until the procedure execution finishes. Is there any way (setting/preference) to enable SQL Developer to be able to run multiple queries at the same time?
    I really would like to move away from TOAD, but this is a major showstopper for me.
    Thanx for any tips.
    Alex

    Hi!
    This post is going to be a little longer, but I have to clarify things out.
    I did not mean to throw any wild accusations, because I did my fair share of RTFM and searching the help. I can tell you that if you put any of these in the help search box:
    session
    non shared
    non-shared
    connection
    concurrent <- I guess this one should yeld something
    multiple
    spawn
    you won't find anything usefull, the article that comes closest, is this:
    "Sharing of Connections
    By default, each connection in SQL Developer is shared when possible. For example, if you open a table in the Connections navigator and two SQL Worksheets using the same connection, all three panes use one shared connection to the database. In this example, a commit operation in one SQL Worksheet commits across all three panes. If you want a dedicated session, you must duplicate your connection and give it another name. Sessions are shared by name, not connection information, so this new connection will be kept separate from the original."
    It does not mention any spawning of non-shared connections from the current one, nor it does mention using a accelerator key combo. But since there could be written something about it, I guess you could call it a documentation bug, because it does not provide any clue to this functionality. The help is definitely of no help in this case. As you can see, I do not throw accusations without trying to find out something first. I guess if someone is not as deep into SQL Developer as you are, there is no way for him/her to know this.
    OK, I tried your suggestion, and (sadly) it does not work as I suppose it should.
    Here's what I did:
    - start a new connection, and enter the following code in SQL Worksheet:
    declare
    j number;
    begin
    for i in 1..1000000
    LOOP
    j := sin(i);
    end LOOP;
    end;
    As you can see, it doesn't do much besides holding the connection busy for a while when executed.
    - start a new non-shared connection from the first one using CTRL-SHIFT-N (as you suggested) and put the following statement in the new SQL Worksheet (with "__1" appended to connection name)
    select sysdate from dual;
    - go to the first SQL Worksheet and execute the procedure
    - while the procedure is executing, go to the second SQL Worksheet and hit F9.
    The sysdate is returned as soon as the first SQL Worksheet finishes and not any sooner. It may run in separate session, but the result is not returned before the other session is finished doing what it is doing. I guess the correct behaviour would be to return the sysdate immediately.
    I verified this behaviour repeating it 3 times starting with a new instance of SQL Developer, each time connecting to another schema and spawning the new non-shared session. The database used was Oracle 10.2.0.3 EE on RHEL 4 UPD3.
    The concurrent execution lacks concurrency. The statements might be executed concurently on the database (i did not went the extra mile to verfiy this), but the returning of results is just not independent of other sessions. To the end user this is as much concurrent as it is serial execution.
    I hope developers get this issue straightened out soon, as I said, I'd love to move away from Toad, but I'll have to wait until they fix this out.
    Is there anything else that can be done to make it behave correctly?
    Kind regards
    Alex

  • Labwindows​/CVI OI crashes when running sequence on the deployed system

    My Teststand Sequence runs fine on the development system. But when I run it on the target system using the Labwindows/CVI OI it sometimes just crashes and the Microsoft bugreporting tool comes up (see attached screenshot). If I run the OI out of the CVI development environment, it only shows a useless segmentation fault message when it crashes.  Any ideas, how to find the reason for the crashes ?   
    Is there any option ( other  than making screenshots) to save the information collected by Microsoft  and to use it for finding the bug ?  

    Hi Allen,
    Yes it is a popup panel used for input of serial and part number in a customized preUUT callback. 
    But installing But installing CVI runtime 8.0 doesn't solve the problem.
    It still sometimes crashes and sometimes the popup panel looks hosed (see attached pictures).  In that case running the sequence was OK and the during the next run of the preUUT callback the panel looked OK again. But when closing the OI ,there were error messages  ( see attachment) .
    It seems that there is some memory corruption going on, but where ?  The code in the preUUT callback seems to run fine on the development system ( neither crash nor corrupted panel) and is also used in two other sequences running on other PCs without showing that problem so far.
    Attachments:
    anweisung.png ‏7 KB
    numbers_damaged.png ‏4 KB
    numbers_normal.png ‏4 KB

  • Query database fields are the same character but not in the same order

    Hello Oracle WIZ !
    I have a simple question regarding perhaps a function.
    I have a columns in a database with data the could have been transpose meaning the keyer might have entered. 1234 and someone else could have come in and put 2134.
    the characters are the same but the numbers are in a different order. Is there any function that would allow me to query just based on characters? hence bringing back the 1234 and 2134 rows?
    Hope this makes sense
    Thanks
    all

    Hi,
    You can use CONNECT BY to re-arrange the characters in a string in ascending order, then use that value to compare strings.
    For example, in the following sample data:
    CREATE TABLE     table_x
    AS
    SELECT     1 AS id,     '1234' AS txt     FROM dual     UNION ALL
    SELECT     2,          '4231'          FROM dual     UNION ALL
    SELECT     3,          '433'          FROM dual     UNION ALL
    SELECT     4,          '343'          FROM dual     UNION ALL
    SELECT     5,          '431'          FROM dual     UNION ALL
    SELECT     9,          NULL          FROM dual
    ;ids 1 and 2 both have txt consisting of '1', '2', '3' and '4'.
    ids 4 and 5 both have txt consisting of '3', '3' and '4'.
    There are no other matches.
    This query finds those pairs:
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= ( SELECT  MAX (LENGTH (txt))
                           FROM        table_x
    ,     got_ordered_txt     AS
         SELECT     x.id
         ,     x.txt
         ,     MIN (SYS_CONNECT_BY_PATH (SUBSTR (x.txt, c.n, 1), ','))     AS ordered_txt
         FROM     table_x     x
         JOIN     cntr     c     ON     c.n     <= LENGTH (x.txt)
         WHERE     LEVEL     = LENGTH (x.txt)
         CONNECT BY NOCYCLE     x.id     = PRIOR x.id
              AND          c.n     != PRIOR c.n
         GROUP BY     x.id
         ,          x.txt
    SELECT     a.id
    ,     a.txt
    ,     b.txt
    ,     b.id
    FROM     got_ordered_txt     a
    JOIN     got_ordered_txt     b     ON     a.id          < b.id
                        AND     a.ordered_txt     = b.ordered_txt
    ;Output:
    .       ID TXT  TXT          ID                                                
             3 433  343           4                                                
             1 1234 4231          2                                                

  • Running file in the same package problem

    I have 2 java file packed in the same package:
    DBConnection.classpackage main;
    import java.sql.*;
    public class DBConnection {
    }t1.class
    package main;
    import main.DBConnection;
    import java.util.ArrayList;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.sql.*;
    public class t1 {
    }They are packed in the same directory, the path is:
    D:\java\project1\main\DBConnection.class
    D:\java\project1\main\t1.class
    When i was in command prompt (window), I tried both of these but encounterd the following error
    D:\java\project1\main>java t1
    D:\java\project1\main>java -cp D:\java\project1\main t1
    I encountered the following errors:
    Exception in thread "main" java.lang.NoClassDefFoundError: t1 (wrong name: main/t1)
    When I tried:
    D:\java\project1\main>java -cp D:\java\project1 t1
    I got this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: t1
    Can anyone tell me the reason? Thx.

    package main;
    import main.DBConnection;You don't need to import a class in the same package.

Maybe you are looking for