Help Dont know what this code is doing ?????

i dont know what this code is doing from the for part can some one explain it for me
i am confused starting at the for statement thanks for the help
public class LeastToGreatestPlaceHolder {
  public static void main(String []args) {
     int [] myArray;
     myArray = new int[3];
     myArray[0] = 6;
     myArray[1] = 7;
     myArray[2] = 9;
    for (int i = 0; i < 2 ; i++){     // confused here
     for(int j = 1; j < 3; j++) {
       int placeholder = myArray[j];
       if (myArray[i] > myArray[j]) {
         myArray[j] = myArray;
myArray[i] = placeholder;
System.out.print(myArray[0]);
System.out.print(myArray[1]);
System.out.print(myArray[2]);

Have you tried running the program and seeing what it outputs?
Have you considered writing out the state of the array and running through the code by hand?
I'll give you a [head start|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html].

Similar Messages

  • Anyone know what this code is doing?

    Howdy,
    Don't suppose ya know what this code could be doing:
    TABLES:  nast,
            *nast.
      SELECT * FROM  *nast
             WHERE  kappl       = nast-kappl
             AND    objky       = nast-objky
             AND    kschl       = nast-kschl
             AND    spras       = nast-spras
             AND    parnr       = nast-parnr
             AND    parvw       = nast-parvw.
        IF *nast-vstat = 1.
          processed = 'X'.
        ENDIF.
      ENDSELECT.
      CHECK processed NE 'X'.
    Its got me stumped! what on earth is *NAST?
    Are we simply looping through all the entries in NAST???
    Basically I came across this code because I am trying to write a program that gets triggered when the user saves a Debit note.
    My program should then take the billing document number that was saved and use it to create a credit memo request, but finding the billing document number was a pain and someone told me that I had to use NAST or something...
    ANyhow, I came a cross the following code but it doesn't make sense...
    I think it should be
    TABLES:  nast.
    data: wa_nast type NAST.
      SELECT single * FROM  nast into wa_nast
             WHERE  kappl       = nast-kappl
             AND    objky       = nast-objky
             AND    kschl       = nast-kschl
             AND    spras       = nast-spras
             AND    parnr       = nast-parnr
             AND    parvw       = nast-parvw.
        IF nast-vstat = 1.
          processed = 'X'.
        ENDIF.
    What do you all think?????

    Thanks Rich,
    May be you are right or may be I didn't amke myself clear.
    I think my program will be connected to the output type via transaction NACE. Then whenever the user saves a debit memo it will trigger the output type and this should then trigger my program to produce the BDC based on the billing document number in the debit memo.
    I thought this would be passed into nast-objkey and I thought I would write an entry routine that could be placed in NACE that access my program.
    AM I correct in thinking that this would work????

  • Need help; dont know what this feature is called

    I once read about this feature in Dreamweaver where you could send an editable version of a web page (or pages) to a client to edit. They could make the revisions and send them back to you... and I dont think the client has to have Dreamweaver installed to make the edits. Does this sound like anything that Dreamweaver has?
    Thanks.

    If you build the site to include some form of Content Management System (CMS), client could log-in to the site and make limited changes to text and images from their web browser.   I don't know if that is what you're looking for...
    Some popular CMSs:
    Cushy CMS
    Content Seed
    WordPress
    Drupal
    Joomla
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • I download a file in the torrent site which is MP4 but unfortunately i tried to delete it but i can not. but all the files that i have is easily to delete only MP4 files i can't delete in the download foldeer please try to help dont know what to do please

    i download a file in the torrent site which is MP4 but unfortunately i tried to delete it but i can not. but all the files that i have is easily to delete only MP4 files i can't delete in the download foldeer please try to help dont know what to do please

    Well you can sync your iPod/iPhone to yur computer or laptop then take the photos off of your iPod like taking photos of of a SD card (from a normal camera) or off of a USB..! Good Luck. plz tick this saying This solved my question if it helps you.

  • HELP dont know what to do!!

    Hi, Just wondering if anyone can help! I really dont know what to do! I am trying to restore my ipod and it says when i click retore 'firm wire disk write error' i really dont know what do about that just wondering if anyone knows here?? Thanks

    The thing is, that you must try the suggestions in that article. There are other things that you can try in this post also.
    http://discussions.apple.com/message.jspa?messageID=1533747#1533747
    They're not easy to follow if you're not computer savvy. Do you have someone at home who can assist and take you through the steps?
    There is also a simple thing you can try such as trying another port on your computer. Some ports are not connected direct to the motherboard and do not recognize the iPod as well as those that are. Reset the iPod each time you connect it to another port.
    The error means that the computer is having a hard time writing data to the iPod's hard drive, and there could be many reasons for this.
    How about taking the iPod to an Apple store? Isn't there one at the Trafford centre?

  • Running thread - which statement to get to know what this thread is doing

    Hallo,
    I have a thread in my database running.
    Normally the action I am doing with this thread lasts 1 hour. Now it is working for 3 hours.
    How can I get to know what my thread is doing and how long this will last? Which statement can I use?
    Thanks in advance, Jadexy

    This query shows what a session is doing:
    select s.sid
    ,(a.APPLICATION_WAIT_TIME / 1000000) as APPLICATION_WAIT_TIME
    ,(a.CONCURRENCY_WAIT_TIME / 1000000) as CONCURRENCY_WAIT_TIME
    ,(a.CLUSTER_WAIT_TIME / 1000000) as CLUSTER_WAIT_TIME
    ,(a.USER_IO_WAIT_TIME / 1000000) as USER_IO_WAIT_TIME
    ,(a.CPU_TIME / 1000000) as CPU_TIME
    ,(a.ELAPSED_TIME / 1000000) as ELAPSED_TIME
    ,a.ROWS_PROCESSED
    ,a.disk_reads
    ,a.buffer_gets
    ,a.direct_writes
    ,a.optimizer_mode
    ,a.sql_text
    from v$session s, v$sqlarea a
    where s.sid = &YOUR_SESSION_ID
    and a.sql_id = s.sql_id
    order by 1
    Times are shown in seconds.

  • Array help, dont know what im doing

    All i am trying to do is read in one line of test from an input file and then tokenizer the fist line and place each string char into an index in list format into an array
    Ex, TFTFTFTFT
    Array =
    T
    F
    T
    F
    T
    F
    T
    F
    T
    So later i can make another array and then compare the two , please dont use super complex code still learning , thanks
    import java.io.*;
    import java.util.*;
    public class History
         public static void getAnswers(BufferedReader inp, String[] answers) throws IOException
              int i;
              StringTokenizer token;
              String str;
              str = inp.readLine();
              token = new StringTokenizer(str);
              for(i = 0; i < answers.length; i++)
                   answers[i] = token.nextToken();
         public static void printArray(String[] answers)
              int index;
              for(index = 0; index < answers.length; index++)
                   System.out.println(answers[index] + " ");
    import java.io.*;
    import java.util.*;
    public class HistoryTest
         public static void main(String[] args)throws FileNotFoundException,IOException
               BufferedReader inp = new BufferedReader(new FileReader("a:\\Input.txt"));
             PrintWriter outfile = new PrintWriter(new FileWriter("a:\\outfile.out"));
             History hs = new History();
              String[] answers = new String[20];
              hs.getAnswers(inp, answers);
              hs.printArray(answers);

    is this allowed, My answer array prints out fine my other two arrays do not, this is input file
    TFFTFFTTTTFFTFTFTFTF
    ABC276 TTFFTFTFTFTTFFTTFFTF
    HTYD22 TTFFFTFTFTFFFFTFTFTF
    HDHJHH TTTTTTTTTTTTTTTTTTTT
    FHSDYG FFFFFFFFFFFFFFFFFFFF
    import java.io.*;
    import java.util.*;
    public class History
         public static void getAnswers(BufferedReader inp, int[] answers) throws IOException
              String str;
              int i;
              for(int g = 0; g < answers.length; g++)
                   answers[g] = inp.read();
         public static void printArray(int[] x)
              int index;
              for(index = 0; index < x.length ; index++)
                   System.out.println(x[index] + " ");
         public static void getRestofInfo(BufferedReader inp, String[] student, int[] responces) throws IOException
              StringTokenizer tokenizer;
              String strstudent;
              strstudent = inp.readLine();
              tokenizer = new StringTokenizer(strstudent);
              //can use student.length for both array termination varible since student # must == responces
              for(int i = 0; i < student.length; i++)
              {     student[i] = tokenizer.nextToken();
                   responces[i] = Integer.parseInt(tokenizer.nextToken());
    } import java.io.*;
    import java.util.*;
    public class HistoryTest
         public static void main(String[] args)throws FileNotFoundException,IOException
               BufferedReader inp = new BufferedReader(new FileReader("a:\\Input.txt"));
             PrintWriter outfile = new PrintWriter(new FileWriter("a:\\outfile.out"));
             History hs = new History();
              int[] answers = new int[20];
              int[] responces = new int[20];
              String[] student = new String[20];
              hs.getAnswers(inp, answers);
              hs.printArray(answers);
              System.out.println();
    } 84
    70
    70
    84
    70
    70
    84
    84
    84
    84
    70
    70
    84
    70
    84
    70
    84
    70
    84
    70
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    null
    Press any key to continue . . .

  • Dont know what this error message means

    hi
    while running the file i get this error whick i dont really know what it means
    dragon% java Text2Bin
    Exception in thread "main" java.lang.NumberFormatException: For input string: "true"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:426)
    at java.lang.Integer.parseInt(Integer.java:476)
    at Text2Bin.main(Text2Bin.java:35)
    [dragon:cosc1309/Assignments/Assignment1] dragon%
    my code
    public class Text2Bin implements Serializable {
    public static void main(String[] args) throws IOException{
    String name;
    BufferedReader in = null;
    //PrintWriter out = null;
    Text2Bin p2b = new Text2Bin();
    PizzaEater myPizzaEater = new PizzaEater();
    FileReader frin = null;
    String line;
    try {
    in = new BufferedReader (new FileReader ("in.txt"));
    while ((line = in.readLine()) != null) {
    line = in.readLine();
    myPizzaEater.setName(line);
    line = in.readLine();
    myPizzaEater.setMslices (Integer.parseInt(line));
    line = in.readLine();
    myPizzaEater.setVslices (Integer.parseInt(line));
    line = in.readLine();
    myPizzaEater.setTslices (Integer.parseInt(line));
    line = in.readLine();
    myPizzaEater.setHalal (Boolean.valueOf(line).booleanValue());
    frin.close();
    in.close();
    catch (IOException ioe) {
    System.out.println(ioe.getMessage());
    catch (NegativeNumberException nne) {
    System.out.println ("NegativeNumberException message was: " +
    nne.getMessage());
    try {
    FileOutputStream out = new FileOutputStream ("out.bin");
    ObjectOutputStream outs = new ObjectOutputStream (out);
    outs.writeObject(myPizzaEater);
    outs.flush ();
    catch (IOException ioe) {
    System.out.println(ioe.getMessage());
    }

    thanks i worked it out i read a line in twice at the beginning of the loop which put me 1 line down from where i wanted to be

  • I am tryig to download new version. It tells me error has occured and to try to save to hardrive. I dont know what this means or ho to do this. Icon es not appear to rag into fil

    Am not ble to download new version 5.0. Am prompted hat unknown error has occured and to try saving file to harddrive. i dont know how to do this

    Hi Celia51510,
    Welcome to the Support Communities!
    The article below may be able to help you with this issue.
    Click on the link to see more details and screenshots. 
    I can't tell from your post if you are using a Windows or a Mac Computer.
    Try deleting the iTunes application and redownloading the version you need below:
    iTunes 11.1 Download for Mac
    http://support.apple.com/kb/DL1614
    iTunes 11.1 for Windows (64-bit)
    http://support.apple.com/kb/DL1615
    Cheers,
    - Judy

  • TS3694 i tried to reset/restore my daughters i pod but encountered problem 3194??Does anyone know what this code means?Ta

    can someone pls help me-tried to reset daughters i pod but problem code 3194 comes up.what does this mean???

    See the actions for that error here:
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    iPhone Error 3194 - How to Fix iTunes Error 3194?
      Fix Error 3194 from iTunes during iPhone restore

  • Apple hardware test..i dont know what this message means..please help!!

    hi all..i really need your help. i have been having serious problems with my g4. it has been telling me to restart it while using most of the programs that come with installation. sometimes black lines with wording comes across the screen forcing me to shut it down. now all the programs are quitting one right after the other. i have reinstalled the system. i have no added memory installed...jsut the 256mb standard. tonight i ran an apple hardware test and i got this message. "memory- error detected error code 2mem/3/4:dimmo/built in" what does this mean? do i need more memory and if so where do i get this? thanks so much!

    Based on that information the built in RAM has failed. What you have been seeing is a Kernel Panic. Sadly since it is the built in RAM, adding more memory wont help, not that you cannot doing it, but I don't think it will stop the Kernel Panics. Bad RAM causes OSX problems, namely Kernel Panics so until the problem with the built in RAM is dealt with this will continue to take place. Being built in RAM, that means you'll most likely need a new logicboard. You will have to get your machine repaired if you wish to continue using it.

  • Dont know what this effect is called, help?? how would i do it in FCE?

    hi,
    I need to get two me's in the same shot.
    E.g. i need a video feed of me talking to myself, but in the same shot.
    I could do this with super imposing but am not impressed with the results.
    Is there any other way i could do it, e.g. some way i could tell FCE to place the left half of one video feed together with the right half of another video feed, then merge them??
    Or something that would give a similar effect without a blue/green screen?
    Thanks

    If you tie off the shot, stay on one side for one take, and on the other for the other take, and the light doesn't change, this should be easy to do by placing the shots on top of themselves, and simply cropping the top clip to reveal the bottom.
    Jerry

  • HT201195 I scratched off the redeem code on my iTunes gift card, and now I dont know what the code is because the whole thing came off. What do I do?

    Question is really self-explanatory. I got and an iTunes gift card for my birthday and when I tried to scratch it off, the whole thing came off and now I cant even see the code. What should I do, if I even can do anything?

    You need to contact iTunes store support. 
    Contact iTunes Support
    http://www.apple.com/lae/support/itunes/contact/
    Follow the link for Gifts & Codes (I think).

  • Please help dont know what to do send it or keep it

    guys i need help when ever i turn on and off my ipod i always hear a popping sound in my head phones i tried other headphones but same problem and then suddenly the volume of the headphone that came with my ipod suddenly changed like the volume isnt equal other one is louder than other one. what should i do?

    For one thing I always hear I little popping sound when I turn my iPod off or on and thats normal, but if it's big and the volume is messing up then try taking a fine Q-Tip and cleaning the headphone jack hole with it. Hope that works.

  • What should i do!? (really dont know what this subject might be!)

    Hello.
    I have a 3 year old MB, and recently i formatted it for the 1. time, so it was clean. The problem i'm having is, that i also own a Ipod Classic, which where connected to my computer, which i had downloaded games for (thru iTunes Store), now when i plug-in my iPod, i want to transfer my purchases from the Ipod to my computer (i have reconnected my iTunes account with the computer, but not sure its Authorized), but then it says it cant!..
    My girlfriends iPod was also connected to my computer before i formatted it, i also purchased games for this iPod. Can i get these games transfered to her iPod, when she connects it to her own computer (a Windows Vista)?
    Kind Regards
    Mathias Brix

    Out of curiosity, is the phone still under warranty?
    When you say you have unlocked it in India, did Verizon supply you with an unlock code because you met all of their requirements to receive an unlock code, such as being on a Verizon plan which has been in existence for at least 60 days and have no payment problems? After Verizon unlocked your phone, did you complete your contract(which would actually put you outside of the warranty period), or have you left the US, returned to India and have canceled your Verizon contract and paid the ETF, or have failed to pay the ETF?
    Or did you unlock the phone via other methods, which voids the warranty, and now expect Verizon to give you another phone?

Maybe you are looking for