codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  java & files  Archive Import (RKM) at 10:24 on Sunday, June 01, 2003
 

Hi

my program is working without any error

"it sorts an array in descending order then lists the ordered array with the original position of its value "
But i want to use the input and output as files.
i mean that , statement
int [] in1 = { 0,0,0,80,0,0,100,0,0,90,0,0,70,60};
must be as follow
int [] in1 = function that open saved file contains values so we can create an array
also i want save the output ( only the posistions of the values)
in a file (one value in each line)so it can be used by another program

i hope that any one of you can help me
thanks in advance


/******************************************************************/
import java.util.*;
public class Open {


public static void main (String [] args) {

int [] in1 = { 0,0,0,80,0,0,100,0,0,90,0,0,70,60};//input



ArrayList Values = new ArrayList();
HashMap OriginalPosition = new HashMap();
for (int i=in1.length-1; i>=0; i--) {
OriginalPosition.put(new Integer(in1),new Integer(i+1));
Values.add(new Integer(in1));
}

// Sort incoming array
Collections.sort(Values);

// List out sorted values in reverse order, with position numbers
for (int i=Values.size()-1; i>=4; i--) {
int val = ((Integer)(Values.get(i))).intValue();
System.out.print("" + val + " ");
System.out.println(OriginalPosition.get(new Integer(val))); //output
}
}
}









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Cascading Menu
•  Re: How to populate a drop down list from a DB
•  Re: Javascript Disable
•  Re: Need some help with javascript code in Unity!
•  Create anExpanding/Collapsing Tree Menu for this Tutorial
•  Creat A Calendar With PHP
•  Re: How to access style attributes in DOM using Javascript?
•  Re: Javascript foldout menu help!
•  Ask for Help!


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011