Quick question on Arrays

I have this bit of code
public class BubbleSort {
public static void main(String[] args) {
for (int st=0; st<args.length; st++){
int st_to_int = Integer.parseInt(args[st]);
System.out.println(st_to_int);      
how can I convert st_to_int to arrays[7] of interger of 7 ARRAYS

Dear warnerja,
I tried it but it came up with this error
BubbleSort.java:12: ']' expected
                    int st_to_int[st] = Integer.parseInt(args[st]);
^
reply to
If I interpret your question correctly, I think you want something like:
int[] st_to_int = new int[args.length];
for (int st = 0; st < args.length; st++)
st_to_int[st] = Integer.parseInt(args[st]);
}

Similar Messages

  • Very simple and quick question about Arrays

    Hi,
    I have the following code to produce a student grades provessing system. I have got it to store data in the array, i just cant figure out how to add the integers from the row to produce a total. Thats all I want to do create a total from the 6 marks and add a percentage.
    Any help would be greatly appreciated.
    -------------CODE BELOW----------------------
    import java.util.*;
    public class newstudent1_2
    public static void main (String[]args)
    System.out.println ("-----------------------------------------------"); //Decorative border to make the welcome message stand out
    System.out.println (" Welcome to Student Exam Mark Software 1.2"); //Simple welcome message
    System.out.println ("-----------------------------------------------");
    int [][] mark;
    int total_mark;
    int num_students;
    int num_questions = 9;
    Scanner kybd = new Scanner(System.in);
    System.out.println("How many students?");
    num_students =kybd.nextInt();
    mark = new int[num_students][num_questions] ;
    for (int i=0; i<num_students; i++)
    System.out.println("Enter the Students ID");
    String student_id;
    student_id =kybd.next();
    System.out.println("Student "+i);
    for( int j=1; j<num_questions; j++)
    System.out.println("Please enter a mark for question "+j);
    mark[i][j]=kybd.nextInt();
    System.out.print("id mark1 mark2 mark3 mark4 mark5 mark6 mark7 mark8");
    //This section prints the array data into a table
    System.out.println();
    for (int i=0; i<num_students; i++)
    for( int j=0; j<num_questions; j++)
    System.out.print(mark[i][j]+"\t"); //the \t is used to add spaces inbetween the output table
    System.out.println();
    --------------END OF CODE---------------
    Thanks.

    I had to do this same sort of thing for a school assignment but i didnt use an array.
    import java.text.DecimalFormat;
    import TurtleGraphics.KeyboardReader;
    public class grade_avg
         public static void main(String[] args)
              int grade, total = 0, count = 0;
              double avg = 0.0;
              KeyboardReader reader = new KeyboardReader();
              DecimalFormat df = new DecimalFormat("0.00");
         for (;;)
                   grade = reader.readInt("Please enter a grade: ");
              if (grade > 0)
                        total = total + grade;
                        count ++;
              if (grade == 0)
                        avg = total / count;
                        System.out.println("The average is: " + df.format(avg));
                        System.exit(0);
    }output looks like:
    Please enter a grade: 100
    Please enter a grade: 50
    Please enter a grade: 0
    The average is: 75.00

  • Quick Question on Arrays.fill() Method

    Does this work for a multidimensional array? I've tried and I can't get it to.
              double stuGrade[][];
              stuGrade = new double[3][125];
              Arrays.fill(stuGrade, -1); //Have also tried Arrays.fill(stuGrade[][], -1) error: Cannot resolve symbol
    symbol: method fill (double, int)
    Have imported java.util.Arrays....
    I need to set all values in atleast one row to a negative number. I haven't had a chance to look at vector (is that it?) arrays. So every element may not be populated. Since it is possible for an entry to be zero, I can't use a condition of not equal to zero to determine whether the loop should continue processing or not....
    Thank you!

    fill(double[] a, int fromIndex, int toIndex, double
    val)
    Where a is your array.... so really your just missing
    your fromIndex and toIndex... no worries.Seeing as how the OP's array is a double[][] rather than a double[], the worries will continue. The fromIndex and toIndex are optional; if he's wanting to fill a single entire array, the fill(double[] a, double val) is fine.

  • Copy Array Quick Question

    Just a quick question.
    Say I have an array A = [1,2,3,4,5]
    B = new int[5]
    I understand to copy the elements of A into B we could use a for loop.
    But can somebody explain to me why you can't just go B = A?
    Does this just cause B to point to A?
    So how do arrays work exactly? Is it like in C where each element is actually a pointer to the data, or does Java copy the data directly into the array element?

    Kayaman wrote:
    JT26 wrote:
    Array A=[1,2,3,4,5] ----> Here A is a reference variable which points to memory locations A[0],A[1],A[2],A[3],A[4] which could not be continueous.Actually no. What you have there is a syntax error. And please don't confuse people by talking about non continuous memory locations. That's simply wrong.And 100% irrelevant for the question at hand.
    >
    B = new int[5] -----> Here B is another reference variable points to an array which could hold 5 elemets.That is correct, basically.
    All the five element holders of B could be physically any where in the memory, thus copying the the elements is done via a for loop.No, Java is smart enough to store arrays sequentially in memory. And the smart way to copy large arrays is System.arrayCopy().Or java.util.Arrays.copyOf.

  • Quick Question: When to use ( ) and when to use [ ] and why the ( *)

    Hi all,
    A quick question that i'm sure is very simple but is slightly confusing me. I've just started trying to learn Objective-C and am a little confused by ( ) and [ ].
    I get that you use the [ ] brackets when you want something specific from an object, i.e.
    [ textField textColor ]
    and that you use ( ) brackets for things like:
    if ( x == y) {
    But I get confused when I see things like:
    NSLog(@"some text here");
    Why does that get ( ) brackets and why is it not [ ].
    Also another point of confusion, creating methods... Why are some methods done like:
    - (void)awakeFromNib
    And others done like (with the additional "*" added):
    - (NSString *)stringvalue
    As I said, I'm sure this is very simple and obvious, but it is confusing me slightly.
    Thanks in advance!

    Adam:
    As you already know, square brackets are used to send a message to an object, so if a object like myObject implements the method -doSomething, you can call it with:
    \[myObject doSomething\];
    The other use square for brackets have is to index C-style arrays, such as:
    aValue = anArray\[10\]; // Get the 10-element of an array
    However, because C-style arrays are rarely used in Cocoa applications (use NSArray instead) you will not see this situation often.
    Parenthesis in expressions are used to group and prioritize, such as:
    x = 10 * (3 + 5); // x = 80
    If () statements use it to delimit the test expression. Same with while (). for () uses it to enclose the limits and increment statements, etc.
    The other important use of parenthesis is in calling a C function:
    result = foo(3);
    means that you are calling the function named foo with the argument 3, and storing the the return value in the variable 'result'. This is different from a message because a C function is not a method of an object. They exist independently of any objects. NSLog() is a function defined within Cocoa but it is not a method. So, you call it with the traditional C function call syntax. Cocoa defines other functions like NSStringFromRect(), which takes an NSRect as argument and returns a pointer to an NSString.
    And that leads me to your last question. Some methods return simple types, like int, float, or void (i.e. returns no value). These methods will have prototypes like:
    \- \(void\)returnNothing;
    \- (int)returnInteger;
    Other methods return pointers to types, like:
    \- (int \*)returnPointerToInteger;
    \- (void \*)returnPointerToAnything; // In obj-C one typically uses id instead of void*
    Returning whole objects from methods has problems and it is better to just return a pointer (the address in memory) instead:
    \- (NSString *)makeAString;
    The method above returns a pointer to an NSString rather than the entire object.
    Good luck with your learning,
    Juan-Pablo
    Message was edited by: Juan Pablo Claude

  • Quick Question: Setting Render File Location

    Hi all,
    Quick question. I'm guessing with all the disappointment, the answer will be no, but I fully realize that I could have overlooked something so its worth asking!
    In FCP7 (familiar phrase huh?) you could explicitly set a location for render files. I understand that you can save FCPX Events on different drives, as well as your projects, however it appears as if the Render Files are getting saved with a folder which also contains your .fcp project file.
    I ask because I like having my project file on my internal so my Time Machine will pick it up when I have it hooked up, but all of those render files take up loads of space and I'd like that on my external media drive instead.
    Is there:
    a.) A way to tell FCPX to store Render Files in a different location
    OR
    b.) A way to move the Render Files to a different location without screwing up FCPX's ability to recognize the project and load it properly.
    If so, great! If not, I'll send it along as a suggestion among with some others. Other than those overlooked technical aspects, I'm kind of digging the UI of FCPX and background rendering is saving me so much time its not even funny.

    Hi Jorgen
    I spent a bit of time on this today without any success.
    In our studio, it's only me that edits... but I use a laptop and a macpro when things get serious. I have a RAID array tyed to the Macpro, and I access it with my laptop via gigabit ethernet.
    I created aliases, and when I opened FCPX, nothing appeared. I also was not able to change the name of events I created, and while it would write the project name and events to the new aliased directories... when I reopened FCPX the events and projects were missing.
    I then tried symbolic links via the terminal. No luck. I then checked ownership permissions, and made sure the permissions were ignored for the drive and everything was world readable and writable. No luck.
    Have you had a chance to experiment with this yet?
    Thanks

  • Report Generation Toolkit Error Quick Question

    Hi,
         I created the most awesome LabVIEW report ever at my desk using a trial version of the RGT and Office 2003.  I took this to my production machine and ")@#(&%(*#^%()^!!!"  The production machine has office 2007 and a fully licensed version of the RGT.  Both machines have LabVIEW 8.6.0.  I've read all the stuff about these errors and something about classes and dll's and whatnot's.  So my quick question, is:  Instead of matching the versions of Microsoft Office as recommended, can I just rewrite from scratch the VI that creates this world's most awesome LabVIEW report on the production machine to create the same effect? 
    Solved!
    Go to Solution.

    Hi 
    Quick Answer: Probably
    Slower answer: Microsoft changed a lot of things behind the scenes in Office 2007, but the Report Generation toolkit version 1.1.3 supports Office 2007 so you should be good to go. Depends on what functions are included in your VI. Liek the read me says "Several default settings in Microsoft Office 2007 differ slightly from previous versions. Reports you generate using Office 2007 might look different than reports you generate from other versions of Office because font sizes, cell sizes, and so on, differ."
    Best Regards
    David
    NISW

  • Two quick questions about Library after moving beginning on a new computer

    Hi there,
    I just moved from Windows to Mac, meaning I had to move my iTunes library from the old PC to my new MBA.
    Just a couple of quick questions.
    1. When I started iTunes on my new Mac, in the preferences I directed the media folder to the folder with all my itunes music/podcasts etc, and then I imported the Library XML file.  Is this incorrect? Should I have imported a different file? Should I have used the itl file instead? 
    If so, should I delete the library and start again?  (if this is the case, please suggest the best way of doing this without affecting my media)
    - a kind of sub-question to this one:  some of the media files arent showing up in the iTunes library, but they are in the media folder on the ext HDD.  Is there a way I can find out which ones havent been recognized by iTunes?  Whats the best way of getting them in to my library?
    2. Pretty much half of my podcasts have not been loaded in the new iTunes.  The ones that havent were ones that I subscribed to on my iPhone, whereas the ones that show up in iTunes were ones I downloaded from iTunes.  When I connect my iPhone and sync it with iTunes, will those podcasts show up in iTunes?  Or is there a risk that they will be deleted from my iPhone?
    Cheers,

    The .xml is lacking some information such as ratings, date added, and play count.  Using the .itl includes this information but cannot be imported using the method you did.
    A complete library is everything in the iTunes folder.  By using the method you did you left the artwork behind in the artwork folder on the other machine.
    Selecting the media folder in preferences does not get iTunes to recognize the media.  All it does is tell iTunes to start storing new media in that location.
    Using the method I outlined nothing will be missed (with the exception of WMA) because you aren't rebuilding your library, you are using the one that already exists.
    You don't have to re-copy everything as long as you get the stuff you missed and re-assemble it all as it was before except not on the Mac.
    What are the iTunes library files? - http://support.apple.com/kb/HT1660
    More on iTunes library files and what they do - http://en.wikipedia.org/wiki/ITunes#Media_management
    What are all those iTunes files? - http://www.macworld.com/article/139974/2009/04/itunes_files.html
    Where are my iTunes files located? - http://support.apple.com/kb/ht1391

  • Quick question re select-options

    Hi
    I am relatively new to ABAP but have a quick question:
    I need to create a select-options which does the following:
    1. Allows ONLY "equals" signs
    2. Disallows intervals
    3. Disallows the use of ranges in the multiple selection box.
    4. Allows multiple individual selections.
    I can achieve most using the following:
    select-options s_knvh for knvh-kunnr no intervals.
    However, this still allows ranges using the multiple selection box, and also allows the "not equal to" option.
    Adding the "no-extension" syntax simply removes my ability to use multiple individual entries.
    Any ideas?
    Thanks
    Jon

    Use this FM.
    SELECT_OPTIONS_RESTRICT

  • A quick question about WebDynpro SLD and R/3 with concurrent users

    Hello ,
    I have a very quick question about Webdynpros and SLD connecting to an R/3 system, when you configure a webdynpro to connect to an R/3 system using SLD, you configure a user name and password from the R/3  for the SLD to use. What I would like to know is when I have concurrent users of my webdynpro, how can I know what one user did in R/3 and what another user did? Is there a way for the users of the web dynpro to use their R/3 credentials so SLD can access the R/3? Like dynamically configuring the SLD for each user?
    - I would like to avoid leaving their their passwords open in the code ( configuring two variable to get the users username and password and use these variables as JCO username and password )
    Thanks Ubergeeks,
    Guy

    Hi Guy
    You will have to use Single Sign On to achieve this. In the destination you have defined to connect to R/3 , there is an option to 'useSSO' instead of userid and password. This will ensure that calls to R/3 will be with the userid that has logged into WAS. You wont need to pass any passwords because  a login ticket is generated from WAS and passed on to R/3. The userid is derived from this ticket.
    For this to happen you will have to maintain a trust relation ship between R/3 and your WAS ,there is detailed documentation of this in help files. Configuration is very straight forward and is easy to perform
    Regards
    Pran

  • QUICK QUESTION ABOUT PORTS

    Hi, I have a quick question about port forwarding/mapping. My question, lets say I am running MSN messenger, who's ports are 6880-6900. But lets say I am running a torrent application or something else that requires those ports. If both applications were running at the same time, would this cause interference with them on the same ports or now. Thanks
    Nathan

    Normally, only one application can listen to a specific port number at a time. If MSN is grabbing those 21 ports then your torrent app won't be able to run.
    However, most apps don't work that way - even if they use multiple ports, they don't use them all at the same time, so MSN might use 6880 when it starts up, leaving the others open for other applications to use if needed.
    Only experimentation will answer that one.

  • 2 Quick Question

    Hello - I'm pretty new to Motion and have 2 quick questions:
    1) If you've got a bunch of keyframes on a timeline and want to make the entire sequence longer - is there a way to just pull the last frame out and have it automatically interpolate the keyframes in between so that it keeps the same timing and everything... it just makes the whole sequence take longer?
    2) On the same timeline with a bunch of keyframes, can you apply one long Interpolation (ala "Ease Out") to the entire thing from A-Z so that the whole sequence eases out rather than just keyframe to keyframe?
    Thanks!!
    Jason

    Heya,
    1. If you're asking if you have something like the "roving" keyframes in AE...well, kinda. Keyframes on footage, shapes, generators, particles, replicators—objects that create an image—don't seem to scale. But keyframes on secondary objects like behaviors and filters do scale.
    2. Very easy: go into the Keyframe Editor and click on the animation state icon/menu for the parameter you want to change. The icon/menu is the last column after the parameter's value in the left-hand side of the Keyframe Editor. If you pick an interpolation type in that menu, it applies it to all keyframes in that particular curve. It's also the same place where you can set the before/after extrapolation, like ping-pong, progressive, etc.

  • Hi, I have quick question about use of USEBEAN tag in SP2. When I specify a scope of SESSION for the java bean, it does not keep the values that I set for variable in the bean persistent.Thanks,Sonny

     

    Make sure that your bean is implementing the serializable interface and that
    you are accessing the bean from the session with the same name.
    Bryan
    "Sandeep Suri" <[email protected]> wrote in message
    news:[email protected]..
    Hi, I have quick question about use of USEBEAN tag in SP2. When I
    specify a scope of SESSION for the java bean, it does not keep the
    values that I set for variable in the bean persistent.Thanks,Sonny
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Quick question regarding best practice and dedicating NIC's for traffic seperation.

    Hi all,
    I have a quick question regarding best practice and dedicating NIC's for traffic seperation for FT, NFS, ISCSI, VM traffic etc.  I get that its best practice to try and separate traffic where you can and especially for things like FT however I just wondered if there was a preferred method to achieving this.  What I mean is ...
    -     Is it OK to have everything on one switch but set each respective portgroup to having a primary and failover NIC i.e FT, ISCSI and all the others failover (this would sort of give you a backup in situations where you have limited physical NICs.
    -    Or should I always aim to separate things entirely with their own respective NICs and their own respective switches?
    During the VCAP exam for example (not knowing in advance how many physical NIC's will be available to me) how would I know which stuff I should segregate on its own separate switch?  Is there some sort of ranking order of priority /importance?  FT for example I would rather not stick on its own dedicated switch if I could only afford to give it a single NICs since this to me seems like a failover risk.

    I know the answer to this probably depends on however many physical NICs you have at your disposal however I wondered if there are any golden 100% rules for example FT must absolutely be on its own switch with its own NICs even at the expence of reduced resiliency should the absolute worst happen?  Obviously I know its also best practice to seperate NICs by vender and hosts by chassis and switch etc 

  • Quick Question - Setting up Personal Domain with godaddy

    Hi there
    Just a quick question to make sure I've done this correctly?
    Ok, I've published my iWeb website.
    I've purchased a personal domain with godaddy.
    I've set up the personal domain in my mobile me account.
    I then logged into my godaddy account and went to 'Total DNS Control and MX Records'
    I changed the following under CNAME (Aliases)
    www web.me.com 1 Hour
    and then added a new CNAME Record
    www.*******.com web.me.com 1 Hour
    Have I done this all correctly?
    Will it take a few hours to take effect?
    Anything else I need to consider?
    Thanks for reading.
    Ross

    CNAME settings can take up to 24 hours to take effect.
    As long as you have forwarded your domain name to web.me.com, then it should be okay.

Maybe you are looking for

  • Editable field in alv

    hiii when doing editable field in alv you set i_fieldcat-edit = C_X i_fieldcat-input = C_X P_selfield-refresh = C_X this is not working when i click on save the internal table is not keeping the change i have edit on the screen and the p_selfield val

  • Is there a Function module to get customer hierarchy data?

    Howdy, I'm writing a report where the user can, on the selection screen, enter a customer number or a hierarchy node and then the program has to get all the higher level nodes and  and lower level nodes for the selected Sales area. eg. for the follow

  • Trouble in Modifying calculateMinorAxisRequirements() method of BoxView

    Hi there, I have written a custom View, called TreeView that extends BoxView. Basically, my TreeView lays out all its children on y-axis (so it calls BoxView(element,View.Y_AXIS) in constructor), and displays all its children (except the first and th

  • PB 1.67 HiRes - chimes, won't boot. Tried suggestions in other threads.

    sorry -- I hate cross-posting but i'm not getting many hits in the "Using..." forum. I've tried everything I can find here and elsewhere to get it to boot. The powerbook chimes and the screen stays black. - No beeping as you would expect with memory

  • Problemas para reinstalar Whatsapp

    Ayer, después de tres años usándolo, tuve algún problema con WhatsApp, por lo que reinicié mi móvil. La sorpresa fue que desapareció esta aplicación del móvil y de My Worl. Aparece como desinstalada, pero es imposible reinstalarla. Agradezco mucho un