AAAGGGHH!!! Selection sort with external file!

Hi, i am trying to sort marks from an external file in ascending order, using a selection sort via an existing class StudentMark.
However, i am receiving 1 error when i compile it!!!!
code below:
import java.io.*;
import java.util.*;
class sort
     // method to display the contents of an array
     static StudentMark data[];
     static void displayData(int[] data)
          try
               data = StudentMark.loadMarks();
               for (int index=0; index != data.length; index++)
                    System.out.println(data[index]+"\t");
          catch(Exception e)
               System.out.println(e.getMessage());
     static int positionOfLargest(int[] data, int limit)
     // method to return the position of the largest item
     // in the data with bounds 0..limit
          int largest = data[0];
          int indexOfLargest = 0;
          for (int index=1; index <= limit; index++)
               if (data[index]> largest)
                    largest = data[index];
                    indexOfLargest = index;
          return indexOfLargest;
     public static void selectionSort(int[] data)
     // method to sort the contents of an data into ascending order
          int temporary;
          int position;
          int size=data.length;
          for (int index=size-1; index > 0; index--)
               position=positionOfLargest(data, index);
               // swap numbers
               if (index != position)
                    temporary = data[index];
                    data[index] = data[position];
                    data[position] = temporary;
     public static void main(String[] args)
          int[] data;
          System.out.println("numbers before being sorted\n");
          displayData(data);
          selectionSort(data);
          System.out.println("numbers after being sorted\n");
          displayData(data);
the error is: sort.java:14: incompatible types -                data = StudentMark.loadMarks();
^
Can anyone see what i am doing wrong??
Thanks!!

static StudentMark data[];
data = StudentMark.loadMarks();the error message "incompatible types" means that the type of data and the return type of StudenMark.loadMarks() are not compatible.
in case of we don't know the return type of StudentMark.loadMarks() i could only guess:
class StudentMark {
  public static StudentMark[] loadMarks() {
}if you used that kind of method declaration you should change your declatation of the variable data:
public static StudentMark[] data;then your codeline 14 shouldn't be a problem any longer.
StudentMark[] data and StudentMark data[] ARE different!
hope it helps.

Similar Messages

  • How to map Idoc fields with external file

    Hi All,
    How to map Idoc fields with external file.
    I want to check the settings where Idoc fields are mapped with external file.
    Thanks in advance.
    Regards,
    Govind.

    If you have configured a fileport where on trigger of IDOC you are creating the file, you can look at the message type documentation and get the offset values for each field in each segment

  • I can't put swf or html files with external files like spritesheets on my website.

    Hello,
    I developed a small test-application for my website. I did this using Flash Builder and Starling.
    My website is created with Adobe Muse, if I try to place the SWF, it gives me an error. If I embed the .html file in an html-object, I get a blank screen.
    Every other swf I created that has no external files such as spritesheets works fine, I can either place it or embed in html.
    I have to say that I did not publish the website yet, as it is useless if I can't show my projects on it, but as I said the normal swf files work and the others not.
    Does anyone have a suggestion or solution?
    There must be one because there are a lot of Starling applications (e.g. Hungry Hero) that are embedded in a website.
    Many thanks.

    Hello,
    I developed a small test-application for my website. I did this using Flash Builder and Starling.
    My website is created with Adobe Muse, if I try to place the SWF, it gives me an error. If I embed the .html file in an html-object, I get a blank screen.
    Every other swf I created that has no external files such as spritesheets works fine, I can either place it or embed in html.
    I have to say that I did not publish the website yet, as it is useless if I can't show my projects on it, but as I said the normal swf files work and the others not.
    Does anyone have a suggestion or solution?
    There must be one because there are a lot of Starling applications (e.g. Hungry Hero) that are embedded in a website.
    Many thanks.

  • Linking Tables With External Files

    Hi,
    is there any chance to link the cells of a table in Keynote with external text files like *.txt or *.xml?
    Thanks
    Michael

    If the databases aren't changing (aren't updated regularly), you could dump the data from the table that has mixed 5 and 9 digit zips into either excel or access, Do your LEFT function in Excel/Access, and then join to this spreadsheet/table.
    However, if these tables are constantly changing/updating it wouldn't be a preferred method, I know.
    Sorry, i didn't mean to post this multiple times.
    Edited by: Jsausser on May 18, 2009 9:54 PM

  • Looping Problem with External Files

    This is what I'm trying to build: A swf file (called main)
    that loads 4 external swf files (called intro, one, two, and
    three). At the start, main.swf loads the intro.swf, and it plays
    once. When intro is done, main loads and plays one.swf. This will
    loop until the user hits one of the buttons, and then two or three
    starts playing.
    What I have done already: Coded buttons. Code works.
    What I am having a problem: I want intro.swf to play just
    once, but it keeps looping. It's supposed to play once, and then
    one.swf is supposed to start looping. Is there anyway to tell intro
    to loop just once? (What I've tried already: a stop() function at
    the end of intro.swf clip, publishing intro.swf with 'no loops'
    setting.)
    (Talk slowly; I have almost no idea how to code in
    flash.)

    Edit: Really? No problem? Weird.. I find that all of the
    imported swf files loop infinitely, unless a stop() or
    unloadmovie() function is called, but then I need another button.
    Anyway, I found a workaround, that seems really obvious (in
    hindsight): I just copied the Introduction file into a new scene in
    the Main file. (Algorithm: Preloader, skip to Introduction scene,
    skip back to main scene. External swf files load, depending on what
    button the user clicks on.)
    Even though it's sorted already, I'd still hear what code you
    use. (It might be simplier than what I did.)

  • Updating HTML with external files...

    Is there any way that my customer updates parts of his
    Website using XML for example ? I have created a XML editor for a
    flash application hat works great, but now I need to integrate it
    to a only-HTML-web how do i do it ? thanks in advance..
    (It oculd be any text file... or any other solution you
    suggest... please let me know)

    Spry can use an external XML file as a data source....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Sw Jiten" <[email protected]> wrote in
    message
    news:f54s1e$ool$[email protected]..
    > Is there any way that my customer updates parts of his
    Website using XML
    > for
    > example ? I have created a XML editor for a flash
    application hat works
    > great,
    > but now I need to integrate it to a only-HTML-web how do
    i do it ?
    > thanks in
    > advance..
    >
    > (It oculd be any text file... or any other solution you
    suggest... please
    > let
    > me know)
    >

  • Recursive selection sort stack overflow

    hi, first time posting here.
    i have to write a java method that implements a selection sort. This method must be recursive. ok not a problem. i have come up with this so far
        public int findMin(int index) {
            int min = index - 1;
            if (index < num.length - 1) min = findMin(index + 1);
            if (num[index] < num[min]) min = index;
            return min;
        public void selectionSort(int left) {
            if (left < num.length - 1) {
                swap(left, findMin(left));
                selectionSort(left + 1);
        public void swap(int index1, int index2) {
            int temp = num[index1];
            num[index1] = num[index2];
            num[index2] = temp;
        }which works fine until i toss in a lot of values into the array. this creates a stack overflow, and ive been told that i need to use the divide and conquer method of resolving this issue. I guess this means to split the array up and sort each half seperatly, again and agin, or so im told.
    My question is how do i go about doing this, i am at a loss. Any help at all would be great.
    thank you
    lance

    i get this when i push the array passed about 5500 in sizeI got no problem. Post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and http://www.yoda.arachsys.com/java/newsgroups.html
    It is silly to implement selection sort with recursion, double-silly if you use double-recursion as your current code.
    /* silly but no OOME when used against 5500 element array */
    import java.util.*;
    public class RecursiveSelectionSort{
      static int[] num;
      public static int findMin(int index) {
        int min = index; // your code had a bug here
        if (index < num.length - 1){
          min = findMin(index + 1);
        if (num[index] < num[min]){
          min = index;
        return min;
      public static void selectionSort(int left) {
        if (left < num.length - 1) {
          swap(left, findMin(left));
          selectionSort(left + 1);
      public static void swap(int index1, int index2) {
        int temp = num[index1];
        num[index1] = num[index2];
        num[index2] = temp;
      public static void main(String[] args){
        Random rand = new Random();
        int n = 10;
        if (args.length > 0){
          n = Integer.parseInt(args[0]);
        num = new int[n];
        for (int i = 0; i < num.length; ++i){
          num[i] = rand.nextInt(10000);
        selectionSort(0);
        for (int in : num){
          System.out.print(in + " ");
        System.out.println();
    }

  • Create external file ........

    my system config: windows 7 and Oracle sql developer 11g.......
    I can not create any kind of external file ........
    pls help me with an example ,with below complete steps
    1.create directory
    2.grant directory
    3.create with external file location

    923746 wrote:
    my system config: windows 7 and Oracle sql developer 11g.......Are you describing the configuration of the client machine? The server machine? Or are you running both the client and the database server on one machine?
    1.create directory To create a directory object in Oracle
    CREATE DIRECTORY directory_name
        AS '<<path on server to a directory that exists on the server>>'That assumes that the path you specify in the DDL already exists on the database server
    2.grant directory
    GRANT read ON directory_name TO user_name;
    GRANT write ON directory_name TO user_name;
    3.create with external file location
    DECLARE
      l_file utl_file.file_type;
    BEGIN
      l_file := utl_file.fopen( directory_name, file_name, 'w', 32767 );
      utl_file.put_line( l_file, 'Some text' );
      utl_file.fclose( l_file );
    END;Justin

  • Open file(including external file) problem on Lion

    I have a problem with AppleScript on Lion (OS 10.7) and cannot know what to do...
    I'd like to open an alias file which has some external files. (For example, adobe illustrator's .ai file with some .png or Logic Pro file with audio files) But I cannot do it, it was working perfectoly on Mac OS 10.6. It seems file system had changed on Lion....??
    Opening normal file on Lion >> it works.
    tell application "Finder"
      activate
              open file "test.rtf" of folder "scriptTest" of folder "Desktop" of home
    end tell
    Opening an alias of normal file on Lion >> it works.
    tell application "Finder"
      activate
      open file "testAlias" of folder "scriptTest" of folder "Desktop" of home
    end tell
    Opening an file with external files on Lion >> it works.
    tell application "Finder"
      activate
      open file "testWithImagefiles.ai" of folder "scriptTest" of folder "Desktop" of home
    end tell
    Opening an alias file with external files >> it works on 10.6 but NOT on Lion, just open the window ...
    tell application "Finder"
      activate
      open file "testWithImagefiles.ai" of folder "scriptTest" of folder "Desktop" of home
    end tell
    Is there any idea? 

    I'm not sure what the problem here is - your statement that it "just opens the window" doesn't mean much.  opens what window?  a FInder window? an new illustrator window? a window in your living room? (the last would be very cool, mind you...)
    at any rate, I think the problem is in some confusion over the word 'alias'.  In applescript, alias just means any file system referent: e.g. alias "HD:Users:yourname" is a path specification for your home folder.  file system objects that point to other file system objects are referred to as alias files.  so try one of these two versions instead:
      -- using alias file directly
              open alias file "testWithImagefilesAlias" of folder "scriptTest" of folder "Desktop" of home
      -- resolving alias file first
              open original item of (alias file "testWithImagefilesAlias" of folder "scriptTest" of folder "Desktop" of home)

  • What sort of external drive to use with Time Machine

    Hi all,
    I was wondering if there are requirements to the sort of external drive Time Machine can use: does it have to be a FireWire drive or will an USB drive suffice? Additionally, what would be the best type?
    Wil Dieteren

    Time machine will per default do incremental backups on an hourly, daily weekly and monthly basis. Therefore you need an external harddrive that is larger than the harddrive you are backing up. Depending on how many changes and large files you work with, the requirements for the right size may vary.
    I'd suggest getting an external HD that is at least 150% of your HD. 200% would be more generous.
    I just bought an Iomega MiniMax 500GB and it works great with Time Machine (my iMac's HD is 320GB).

  • File to IDOC, with External Definition to hold multiple IDocs

    Hello Experts,
    I am configuring a sample File to IDOC scenario. Here are the steps I am following, can you please guide me what I am missing here.
    I am having a flat file with 10 records to be transferred to my ECC system through IDOC adapter to create 10 different IDocs.
    1. I am picking up my flat file using a 3rd party Business System with File Content Conversion
    2. I uploaded CREMAS Idoc and exported as XSD file and modified Occurences paramter to unbounded and uploaded back as an External file definition into IR
    3. I defined an SAP WEBAS ABAP type Business System with LS (representing my ECC system) and configured with IDOC Rcvr channel.
    4. In the IDOC recvr Channel, I specified RFC destination pointing to my ECC system & Port, Release...etc
    5. On the ECC side, I configurated a PARTNER PROFILE with the above mentioned LS(used in step 3) and added an Inbound Idoc paramter CREMAS with process code CRE1. Selected the option Trigger Immediately.
    Testing:
    1. When I checked my CC monitoring in RWB, my file on the sourced is getting picked up successfull with respect to the specified polling intervals.
    2. I don;t see any messages in my SXMB_MONI. I verified SXMB_ADM configuration it looks fine to me
    3. I used TCode:WE02 on ECC side, nothing is there
    4. I used Tcode SM58 on ECC side, nothign is there
    I have no idea what is happening after successfully picking up the file on the source side.
    Is there a way to trace where exactly the error is or what is wrong with my scenario?
    Just an observation, We don;t need to specifiy any LS on the Sender Business Sytem(3rd party in my case) which picks up my file on the source side. Rather I am specifiying LS on the Target Business Sytem(type WEBAS ABAP in my case) to send my IDOC to ECC system. I am using the same LS to define PP on ECC system.
    Edited by: Chris Rock on Oct 21, 2008 5:03 PM

    Aamir,
    I tried full cache refresh, also cleared SLD Cache for both IR & ID. No luck.
    I think either some thing wrong in connection parameters, but atleast if I see some error in Moni or RWB, it helps, but in my situation, nothing is showing up there.
    Connections:
    I specified PORT & RFC Dest in IDOC RCVR Adapter along with WEBAS Release version. These PORT & RFCs are created in XI using SM59 & IDX1 and both passed the connection test.
    On the ECC side, I created a PP with inbound Idoc CREMAS and process code as CRE1. This PP uses the LS that was used in RCVR BS specified in XI side.
    I also loaded Idoc meta data into XI with Tcode: IDX2
    Please help me, any body. I will sincerely award the points.

  • Facing problem in .doc to .chm conversion esp with External Map Id file

    Hi...I'm a new user to RH-Word. I need to create .chm file
    from a .doc file (earlier we used to use .hlp). Is it correct that
    i need .cnt (for TOC) and .hlp files as well for the conversion? If
    not, then how can i do it with the .doc file ONLY? Secondly, i have
    converted the .doc to .chm with the help of .cnt and .hlp BUT
    Context Sensitive help is not working in this case. I imported the
    external .map file (that was provided with the VC++ code of my
    program) BUT the Map IDs are placed in the Unused Map ID Folder and
    i need to create aliases for each and every Map ID [which is very
    cumbersome and difficult to do as i don't know which ID was related
    to which Topic]. Is there any way to convert the .doc while
    preseving the Context Sensitive Help as well? Plz help!!

    Hi DivyaVij,
    Can you describe more precisely what you want do do, or what
    you did?
    If you want to convert your WinHelp-project (hpj) to a
    HTMLHelp project (.xpj) in RoboHelp, this is how I would do it:
    - In RH Starter select the tab Import.
    - Select WinHelp Projekt (.hpj). The dialog page Import
    Project - Select Project Format opens where you select HTML Help.
    - The Select WinHelp Project dialog appears where you select
    your WinHelp project.
    - Define the import settings.
    The hh file should convert fine. You may have to manually
    reformat topics, convert bmp files or other stuff, but you will
    work with HTML files, which is much more convenient.
    Hope that helps!

  • "Use RAW files with external editor" greyed out for Photoshop CS2?

    I've just upgraded from iPhoto 5, and the "Use RAW files with external editor" option in the advanced preferences is greyed out when I select Photoshop CS2 as my external editor (back in the General pane).
    It works fine when Preview.app is selected. I can understand that pre-CS2 Photoshop wouldn't be available, but CS2 is capable of editing RAW images.
    Has anyone been able to get iPhoto 6 to send a RAW image to Photoshop CS2 using this preference? I've written an Applescript to do it in iPhoto 5, but I'd rather use something cleaner...
    15" PowerBook G4   Mac OS X (10.4.4)  

    Works great with Photoshop Elements, opens with Camera Raw. The issue is you can't save it so that iPhoto gets the changes.
    You have to save it and then re-import. I tried all permutations of saving it in originals and modified folders in the library. No luck. The only thing I didn't try is to save it as a jpeg over the top of the full sized one iPhoto created on import.

  • Working With Two External Files With T-SQL Commands

    Hi friends,
    In a VSTO Excel AddIn of mine I have come across a need to use T-SQL commands before bringing the dataset on the activesheet, derived from two tables in the shape of external CSV files. However,
    since using SQL Express in this regard requires connection to a server. With Visual Studio as well as SSMS installed on my laptop I'm able to use the said facility but I am unable to distribute such an addin to other team members not having any of the studios
    installed nor access to any server.
    Is there any way to use the similar features on the users' side?
    In other words, how to develop a macro, for example, in which I could consider two CSV files as two different tables as in a database, and carryout some T-SQL functions/commands on the same like:
    UNION of first three columns from both the tables;
    Creating a temporary table with the DISTINCT sets of the said three columns; and
    Then carryout LEFT JOINS between the new table and the earlier two tables;
    to derive a simple comparative dataset?
    Looking forward for you experts' valuable advices in this regard.
    Thanx in advance.
    Thanx in advance, Best Regards, Faraz A Qureshi

    Hi FARAZ,
    As with Excel files, you can also use Odbc driver to connect to CSV files. As long as the user's machine installs the ODBC driver, you can OdbcConnection to connect to the CSV files.
    The sample code to manimulate CSV files with ODBC driver(C#):
    string connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)}; Dbq=C:\; Extensions=asc,csv,tab,txt;";
    using (OdbcConnection conn = new OdbcConnection(connectionString))
    conn.Open();
    string sql = "SELECT u.UserName,u.Age,c.Phone,c.Address FROM user.csv u left join contact.csv c on u.Id=c.UserId";
    using (OdbcCommand cmd = new OdbcCommand(sql, conn))
    But if you want to publish the Add-in to the user's machine, you still need to install the .Net Framework and the VSTO runtime to support the Add-in.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Using an external drive with shared files (iPhoto, iTunes), attached to a Time Capsule, can the contents of the external drive be backed-up to the internal Time Capsule drive? Perhaps a RAID1 mirror to a partition?

    Using an external drive with shared files (iPhoto, iTunes), attached to a Time Capsule, can the contents of the external drive be backed-up to the internal Time Capsule drive? Perhaps a RAID1 mirror to a partitioned Time Capsule? I understand that the Time Machine (software) cannot backup a networked drive (the external) and that Time Capsule (the router/wireless hard drive) does not have its own backup software... so it won't backup the connected drive. What I would like is an alternate solution for having an automated backup of a networked drive. A 2TB Time Capsule has more than enough space for Time Machine backups of my family of Macbooks, so I had hoped to mirror a 500GB external drive (with shared media files) to a portion of the Time Capsule internal hard drive. I assume this would require a partition of the Time Capsule drive. If not, would the sparse file from the various computers being backed up need to be copied to the external drive as part of the RAID1 setup? This seems like overkill for the Time Machine backup, but it would cover the media files.  

    The complexity with this idea is the software has to run from a Mac computer on your network.. so you need a Mac turned on, probably most of the day.
    It isn't possible to partition the TC although you can create a image area.
    The software would have to copy the material, that means all files to be copied, go from USB drive, back to the Mac, then back to the TC, and written to the drive. In other words you have just added Network congestion, although a proper incremental backup type software will not actually use a lot of capacity.
    Finally it will be slow.. network drives are slower than internal drives. Well USB connected drive is much slower than the same drive connected directly to the computer.. and if the drive is connected directly to a computer it can be shared with the network.
    http://www.anandtech.com/show/4577/airport-extreme-5th-gen-and-time-capsule-4th- gen-review-faster-wifi-/4
    Read carefully the speed of the USB drive plugged into the TC.

Maybe you are looking for