Swap Numbers, Help!

I'm new to Java and I'm wondering why this code won't work.
And if you can write this program where it'll just swap two numbers from a user input, how would write it. Help would be greatly appreciated.
class SwapNumbers {
     String[] collectNums;
     public static void main (String arguments[]) {
          SwapNumbers sn = new SwapNumbers();
          for (int i = 0; i < arguments.length; i++) {
               sn.collectNums[i] = arguments;
          String ghostNum;
          sn.ghostNum = sn.collectNum[1];
          sn.collectNums[1] = sn.collectNums[0];
          sn.collectNums[0] = sn.ghostNum;
          System.out.println(sn.collectNums[0], sn.collectNums[1]);

Use methods to do the work, that way you can extend the functionality in the future to handle more than 2 values, for example.
package com.stuff.jdc;
public class SwapValues {
     private String[] values;
     public static void main(String[] args) {
          SwapValues sn = new SwapValues(args);
          System.out.print("Values as entered: ");
          sn.displayNumbers();
          sn.swapValues();
          System.out.print("Values after swapping: ");
          sn.displayNumbers();
      * Constructor.
      * @param args
      * The array of command line arguments
     public SwapValues(String[] args) {
          if (args.length < 2 || args.length > 2) {
               throw new IllegalArgumentException("Must specify exactly 2 arguments");
          values = args;
     public void swapValues() {
          String temp = values[1];
          values[1] = values[0];
          values[0] = temp;
     public void displayNumbers() {
          System.out.println("[" + values[0] + "," + values[1] + "]");
}

Similar Messages

  • My free trail for $29.99 as run out. want to join but i can't find serial numbers. help!

    my free trail for $29.99 as run out. want to join but i can't find serial numbers. help!

    Cloud programs do not use serial numbers... you download & install & activate by logging in to your paid Cloud account
    http://www.adobe.com/products/creativecloud/faq.html
    http://helpx.adobe.com/creative-cloud/help/install-apps.html
    http://forums.adobe.com/community/download_install_setup/creative_cloud_faq
    what is http://helpx.adobe.com/creative-cloud/help/creative-cloud-desktop.html
    Cloud Getting Started https://helpx.adobe.com/creative-cloud/topics/getting-started.html

  • Reading a binary file (byte swapping?): HELP!

    Hi,
    Below are 2 simple programs, one in C and the other in Java that read a binary file. The first 3 integer numbers read by the C program are:
    910, 1024437292, 100002
    The first 3 integer numbers read by the Java program are:
    -1912406016, 749473597, -1568276224
    The file was written with another C program. The values read by the C program listed here are correct.
    I supect that I have a byte swapping problem. Do you know how I can solve this problem? I really can't change the format of the input file.
    Thanks for your help,
    Miguel
    #include <stdio.h>
    void main(int argc, char *argv[]) {
    long buff[600];
    FILE *fp = fopen("c:\\inetpub\\wwwroot\\super\\wvdot3.awg","r");
    fread(buff,sizeof(int),512,fp);
    int sz = sizeof(int);
    import java.io.*;
    public class test {
    public static void main(String[] args) {
    try {
    DataInputStream din = new DataInputStream(new BufferedInputStream
    (new FileInputStream("c:\\inetpub\\wwwroot\\super\\wvdot3.awg")));
    int nrecs = din.readInt();
    int version = din.readInt();
    int routetype = din.readInt();
    System.out.println("read: " + nrecs + " " + version + " " + routetype);
    } catch (IOException exc) {
    System.out.println("IOException: " + exc);

    Yeah, the problem is byte ordering. I had to deal with the same thing, since Java is always big endian, and intel and DEC Alpha are both little endian. I assume you're original program runs on Intel.
    I ended up creating a new LittleEndianDataInputStream. Unfortunately, you can't just extend DataInputStream since all it's methods are final. You can however copy the source, rename it, and then change all the multi-byte numeric methods to reverse the byte ordering.
    For example, here is the code for the original and little endian version of readInt()
    <code>
    // DataInputStream
    public final int readInt() throws IOException {
    InputStream in = this.in;
    int ch1 = in.read();
    int ch2 = in.read();
    int ch3 = in.read();
    int ch4 = in.read();
    if ((ch1 | ch2 | ch3 | ch4) < 0)
    throw new EOFException();
    return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
    // LittleEndianDataInputStream
    public int readInt() throws IOException
    int ch1 = in.read();
    int ch2 = in.read();
    int ch3 = in.read();
    int ch4 = in.read();
    if ((ch1 | ch2 | ch3 | ch4) < 0)
    throw new EOFException();
    // here's the change
    return ( (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0) );
    </code>

  • Numbers Help Please

    Hey I am just starting to use numbers and I need helping figuring something out.
    When you are working on a spread sheet and you are typing in one of the columns, how do you get the column to expand with the more that you write in that column?
    Thanks for the help!

    In the English Version of the Numbers User Guide PDF, see 'Here are the ways to handle content too large for a cell' beginning on page 55, in Chapter 3. Too many ways to list here.
    Jerry

  • Invoices with NUMBERS, help needed, the tax still on the invoice but it does not actually calculate it?

    Hello, I need help to display tax on the invoice, its numbers/ invoices,
    the tax is set to 21%
    it is as is but it does not calculate the tax indeed.
           subtotal    e495
    tax        21%    e0.00
    Total                e495
    any help?
    thank you

    Try reposting in the Numbers Forum

  • Numbers help!

    I've just found out that a completely password protected excel file opened in numbers loses all of the protection and displays previously hidden sensitive data. When I click to open the excel file on my iPad it won't open it but gives me the option to open it in numbers which it then proceeds to imports the excel spreadsheet. Please can someone help? How can we stop all of the protected hidden sheets from being displayed?

    Surely numbers shouldn't convert protected excel files into spreadsheets where everything is visible to people that shouldn't be able to see it?
    If the workbook is protected in Excel, Numbers cannot open it unless the recipient enters the correct password.
    Once the password is entered everything becomes visible and can be edited by the recipient.
    That's just the way it is, so far. If you've got information anywhere in a workbook that you need to keep confidential, then don't give anyone the password to that workbook!
    You may have noticed that in Numbers you can password protect a document.  You can also lock a table to help prevent it from being changed by mistake (though the user can simply unlock it in the menu). But you can't lock specific cells or a sheet.
    SG

  • Image Swap + Click Image Swap & Restore Help

    Hi everyone,
    I'm having trouble figuring this out and was hoping someone could help me with the code. What I currently have is a world map for my books. What I want is to have several hotspots that change the image (the world map) in five ways.
    1. When the mouse goes over a continent it swaps the image of the continent with a rollover, letting you know that continent is clickable.
    2. When the mouse goes out of the continent it restores back to the original image of the world map.
    3. When you click the continent it swaps to a "zoomed in" image of the continent.
    4. The image in #3 (zoomed-in) stays on screen until clicked. Once clicked it then returns to the original image (the world map).
    5. When the continent is double-clicked it sends you to a separate browser with that continent.
    I've got all of them figure out except for #4. As soon as the mouse moves out of the hotspot, the "zoomed-in" image returns to the original image.
    Here is the link to what I have so far: http://christopherdeldridge.com/Photo%20World%20Map.html
    Here is the code I have for one of the hostpots for one of the continets:
    <area shape="poly" coords="335,145,310,134,280,137,255,141,231,144,196,147,170,143,132,146,127,174,144,188,1 64,211,188,211,208,213,231,216,265,217,272,234,295,240,316,227,343,225,357,241,368,226,364 ,203,347,195,315,196,288,198,264,202,246,200,241,171,288,163,315,156" alt="" style="cursor: pointer;" onclick="MM_swapImage('ZenitaSatellite','','Pics/Satellite Map 2/WestVadra 2.gif',1)" ondblclick="MM_openBrWindow('Vadra Photo.html','','')"  onmouseover="MM_swapImage('ZenitaSatellite','','Pics/Satellite Map/WVadra.gif',1)" onmouseout="MM_swapImgRestore()"  />
    Thanks for the help...

    While looking through your code I see several things you should change:
    1.  Your CSS is flawed -
    <style type="text/css" media="all">
    <!--
    .hiddenlink {
    color: #000; /* same color as the surrounding text */
    text-decoration: none; /* to remove the underline */
    cursor: auto; /* to make the cursor stay as the auto cursor, not the hand */
    -->
    <style type="text/css">td img {display: block;}
    .auto-style1 {
    Note that the .hiddenlink rule does not have a closing "}", and that there is an improper opening <style> tag embedded there immediately before the 'td img' rule.
    2.  I also note your liberal use of file/pathnames containing spaces - this is a bad practice as some browsers will assume that a space is the end of the file/pathname.
    Anyhow, I have not tested this but it should work.  You need to set up a toggle on the onclick event call so that you can know which image to load, like this -
    <area shape="poly" coords="622,367,592,366,566,373,542,381,527,391,531,407,556,421,592,424,622,411" alt="" style="cursor: pointer;" onclick="if(alekandria==1){MM_swapImage('ZenitaSatellite','','http://christopherdeldridge.com/Pics/Satellite Map 2/Alakandria 2.gif',1);alekandria=0;} else { MM_swapImage('ZenitaSatellite','','http://christopherdeldridge.com/Pics/Satellite Map 2/Alakandria.gif',1);alekandria=1;" ondblclick="MM_openBrWindow('Alakandria Photo.html','','')"  onmouseover="MM_swapImage('ZenitaSatellite','','http://christopherdeldridge.com/Pics/Satellite Map/Alakandria.gif',1)" onmouseout="MM_swapImgRestore()"  />
    So - when you click on the image, the value of the toggle (a variable specific to that particular image) is tested.  If its value is 1, the image has already been expanded, and you need to swap in the unexpanded image.  You also set the value of the toggle to 0.  If its value is 0, the image is unexpanded, and you need to swap in the expanded image.  You also set the value of the toggle to 1.
    Get it?

  • Ipad numbers spreadsheet corrupted by iMac numbers - help!!

    I have a numbers spreadsheet set up on iPad and used drop down lists to enter simple values. The tables are linked across my ipad. When i opened my spreadsheet via icloud on my iMac, the tables had auto inserted values and or column headers in the empty cells! this affects a number of linked tables and has caused the sum value column to be corrupt please help!!

    Toffee,
    I've had no problems like that, so without more information it will be difficult to help you. You could post a screen shot of your layout. If you turn on the Formula List and take a shot of that too, it may help to determine what is happening.
    Jerry

  • Numbers help with a guest list

    I am a newbie...using numbers for the 1st time for a guest list for an auction...I am up to row 42 to need to add a bunch more and that option is no longer available...HELP!!!

    To add rows you can activate the table by clickin gin any cell, then either:
    1) drag the tale controls to expand columns, rows, or both:
    OR
    2) type the key combination <COMMAND> + arrow (left, right, up, or down) to add a row/column
    OR
    3) you can use the menu items:
    "Table > Add Row Above":
    "Table > Add Row Below":
    "Table > Add Column Before
    "Table > Add Column After":
    OR
    4) you can right click on the row or column header, then select the "Add..." from the contextual menu:
    You can get this, and more, from a free, downloadable, users guide from here:
         http://support.apple.com/manuals/#productivitysoftware

  • Urgent page numbering help

    Hi!
    While I've been able to create separate sections for my document & number them separately (title page through executive summary is one section, Introduction through conclusions a separate section), I can't make the numbering for the sections different.
    Meaning, currently Title page has no number, 1st page - Exec summary are pages 1-4 and Introduction - Conclusions are pages 1-28.
    I would like Title page to be without a number (as it is)
    Exec summary through page 4 need to be numbered i, ii, iii etc.,
    Introduction through Conclusions need to be 1, 2, 3, 4, etc.,
    Every time I try to change the type of numbering I'm using (i,ii or 1,2,3) the entire document changes rather than just the section. So I end up with two sections numbered separately, using the SAME numbering type! Hope this has made sense!
    This report is due this afternoon and I am incredibly frustrated! Quick help would be greatly appreciated!

    Well! Thanks for keeping it EASY for me, Jerry !
    I think this actually just might work. I'm going to go try it. Thank you very much !
    I'm thinking there must be a way to do this in Pages. Must eventually read up on it. Now is not the time though!
    Thanks again!

  • Array of unique random numbers - help?

    basically, i'm trying to create a BINGO card.
    i stared learning Java a week ago and am finding it easy to learn and use....at least so far.
    my instructor gave me the assignment to created a BINGO card. so i used the system.out.format command to make 5 tab fields, 8 spaces each ("%8s %8s %8s %8s %8s", "B", "I", "N", "G", "O"). although the assignment only wanted me to think numbers out of thin air, just to use as examples, i went above and beyond with the idea to make a BINGO card generator that could actually function.
    then i started the random number sequences, using the Math.random() command. all told, there are 24 of these in the program, one for each number on a bingo card. the field in the middle is the FREE space, so it has no Math.random command.
    in BINGO, each letter (one of my five tab fields) can have a number in ranges of 15. B is 1 to 15, I is 16 to 30, etc. it looks similar to this:
    B I N G O
    9 19 39 57 66
    3 28 32 51 74
    3 29 FREE 46 70
    14 28 43 55 67
    9 24 35 59 62
    as you can tell, i'm having trouble with actually making unique random numbers so that none repeat.
    is there a command or string or something to help me accomplish this?

    The best way I've come up with is to use an object to store the numbers that implements Collection--like ArrayList...
    Then you load it with the range of numbers that you want and call, shuffle() on the object, that will randomize your range of numbers and then you can choose the quantity you want from the storage object. So let's say you need 25 number in the range of 1 to 100:
    Add the numbers (you have to use classes so I would do Integers) 1 to 100;
    call shuffle()
    pull back the first 25 numbers
    This will guarantee that each number is distinct and in a random order.
    If you need multiple sheets populated, you can just call shuffle() between population of each sheet.
    package Junk;
    import java.util.ArrayList;
    import java.util.Collections;
    class Junk{
      private ArrayList<Integer> l;
      Junk(){
        l = new ArrayList<Integer>();
      public void loadList(int s, int e){
        for(int i=s; i<=e; i++){
          l.add(new Integer(i));
      public void randomizeList(){
        Collections.shuffle(l);
      public void printList5(){
        for(int i=0; i<5; i++){
          System.out.println(l.get(i));
      public static void main(String[] args){
        Junk j = new Junk();
        j.loadList(10,99);
        j.randomizeList();
        j.printList5();
        System.out.println();
        j.randomizeList();
        j.printList5();
    }

  • Dv6 Hard disk swap OS help

    Hi, I have a dv6-1245dx laptop, and have have determined  (with help from other folks on this forum ) that a failing HD is the cause of some BSOD issues i've been having lately, so I'd like to swap it out and keep this puppy alive a bit longer. 
    The HD is a Fujitsu SATA44 type, and is super easy to get to.  Assuming I get a drive thats exactly the same size, the swap should be a breeze.
    I assume I can get pretty much any laptop 2.5'' hard drive that is SATA, and i'm just gonna get the same size (320GB), so it's not very expensive.  
    My problem though, is how to deal with the OS?  This laptop has vista.  How can I take the old drive out, slap a new one in, and somehow get the OS back onto the new drive ( this was my wifes laptop so if there were original install discs, they are LONG gone )  ?   
    Thanks.

    Hi,
    You're not restricted to any HDD manufacturer, so any 2.5" Sata drive ( 5400rpm or 7200rpm ) will be fine ( you'll need to remove the plastic adapter from the old drive and fit it to the new one - see Pages 78/79 of your Maintenance & Service Guide ) - You may also want to consider installing a slightly larger capacity drive if there's little differnce in cost, such as the example on the link below.
    500Gb Notebook Hard Drive.
    Regarding reinstalling the OS, there are a couple of options.
    1.  Although the Recovery Discs are no longer stocked by HP, they are available at the 3rd party re-seller on the following link.
    http://www.computersurgeons.com/p-16827-recovery-kit-532673-001-for-hp-model-number-dv6-1245dx.aspx
    These discs will reinstall the operating system, all required drivers and nearly all of the original software ( the exception often being trials of MS Office ).  They will also re-create all the original partitions, including the Recovery Partition.
    2.   In the same way that it's possible to create a Windows 7 retail disc, use this to perform the installation and then use the OEM windows 7 activation key from the COA label, the same process is possible if your notebook came with Vista.  A full description ( including links to the Vista Image downloads ) of this can be found on the following link.
    Vista Files & Guide.
    Additional software and drivers you may require can be found Here.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • Swap Images Help

    I have figure out the process of swaping images but now i
    cannot get them to swap like I want them too. I want my little
    pictures to go into the one big picture. Can someone please
    help??

    Typically, you would want to do this in DW, NOT in FW. FW's
    HTML is usable
    for prototyping, but not for production.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "lyssalovely224" <[email protected]> wrote
    in message
    news:g557lv$94h$[email protected]..
    >I have figure out the process of swaping images but now i
    cannot get them
    >to swap like I want them too. I want my little pictures
    to go into the one
    >big picture. Can someone please help??

  • Swap numbers between two smartphones same account?

    hi all I just upgraded to the htc m8 from the htc one, I need to move the old number to the new phone and the new number to the old phone, could you tell me the steps?

        I'd be happy to review your options for processing this change jfaulk1111! Normally, you can make changes like this on My Verizon. However, in this case, it sounds like you're trying to trade phones between lines. You would need a Verizon Representative to process this change for you. You can call 1-800-922-0204, or you can Follow me on this message board, and I can get the details needed to help you complete everything.
    Thank you,
    MichelleH_VZW
    Follow us on Twitter @VZWSupport

  • New to Numbers, help with formula please.

    I am trying to find the formula which best does the following for me.
    I have a spread sheet with four colums.
    Colum A.  Shows Text, heading of locations, eg  Home, Away, Hotel etc.  Then beside these columns i have the days i arrive and depart the locations.  The forth column shows the total of nights spent in each type of accommodation
    Eg
    Ongoing Table
    Home          Date          Date          5
    Away           Date          Date          5
    Home          Date          Date          5
    Hotel          Date          Date          5
    Home          Date          Date          5
    Hotel          Date           Date           5
    Away          Date          Date          5
    As this in an ongoing list, I am looking to have a section that will automatically and continually add up the total nights I spend in different types of accommodation.  So, in summary I can look at it the following way
    Summary Table
    Home          15
    Away          10
    Hotel          10
    So that when I enter in a separate line in my ongoing table, it automatically keeps the running tally in my Summary Table.
    Thanks in advance for your help.

    Dolmio,
    Let's say that your log table is named Ongoing. The expression in your summary table, column B, would be:
    =SUMIF(Ongoing :: A, A, Ongoing :: D)
    Jerry

Maybe you are looking for

  • I am not able to make International calls from iPhone 5s

    I got this new iphone 5s as a gift a week days ago, and It was working all great for 2-3 days. But from last 4days i AM not able to make international calls Whenever I dial, I can't hear any ring going on and all I can hear is my own voice reverting

  • Where used of a table field in BI extraction program

    Hi, How can I find a particular table or table-field is used in any BI extraction program or not? Actually we are doing a modification and change in the structure of a big Z table and custom developments. So I want to analyse and list the programs re

  • BEx Query Designer Error

    Hi All, I have a problem where I have just updated to SP 18 and now the BEx Query Designer comes up with a problem, I can open the Query Desinger but when I go to open a query from my history the Query Designer shuts down immediatly. Has anybody got

  • Not able to attach Adventure works Database to SQL server 2012 Management studio

    Hello while i try to attach AdventureWorks2012 database to SQL Server 2012 Management Studio i am getting the following error Msg 1813, Level 16, State 2, Line 1 Could not open new database 'AdventureWorks2012'. CREATE DATABASE is aborted. Msg 948, L

  • Re: Premium did not get automatically upgraded

    A few changes to your Premium account Group video calling is now free. But as a big thanks for being a Premium subscriber, we're giving you calling to countries around the world at no extra cost.  That means you'll get all the perks of Premium, plus