Array of Integers please help?

pleace can someone help me? i am new in java . i want to create an array integers? Here i hava my codes that creates an array of strings? can anybody convert that so can accept integer and modified my method to add Integers instead of strings?Thanks for your time
public class Numbers implements Serializable {
* A constant: The maximum number of Random numbers
// static public int MAXSETS = 3;
static public final int MAXSETS = 3;
* The integer variable count will hold the number of states in the subset
private int count = 0;
* The array state will hold the States in the subset of states
private String number[] = new String[MAXSETS];
* Constructor method: Reserve space for the 50 Integers
public Numbers() {
for(int i=0;i < MAXSETS;i++) {
number = new String();
* addNumbers: adds a number to the collection of Numbers
* a string with the new number is passed as a parameter
public void addNumbers(String newNumber) {
number[count] = newNumber;
count++;
// System.out.println("scdsddfs"+ state);
* toString: Convert the object to a string
public String toString() {
// int num;
String str = count + " ";
for(int i=0;i < count;i++){
// num = Integer.parseInt(str);
str = number;
// str = str+" "+number;
// System.out.println("scdsddfs"+ str);
return str;

pleace can someone help me? i am new in java . i want
to create an array integers? Here i hava my codes that
creates an array of strings? can anybody convert that
so can accept integer and modified my method to add
Integers instead of strings?Thanks for your time[snip]
You create an array of integers by saying
int[] myArrayOfIntegers[SIZE_I_WANT];To convert a String to an int, use the Integer.parseInt method.
Good luck
Lee

Similar Messages

  • The file just won't load into array...Please Help!

    hi i need some help in loading a binary file into an array so that i can edit the data that was saved from previous run..
    i could save the file but after that when i try to load it back to memory...i can't...ie. all the information keyed in were lost...please help
    this is the Code for the loading process...
         public static void loadAircraft (ArrayList aircraft) {
              try {
                   FileInputStream filein = new FileInputStream(".\\Data\\Aircraft.bin");
                   ObjectInputStream objectin = new ObjectInputStream(filein);
                   Aircraft craft = (Aircraft) objectin.readObject();
                   aircraft.add(craft);
                   objectin.close();
                   filein.close();
              catch (Exception e) {}
         }the above code won't load anything into memory...is there a way for overcoming this?
    inside the Aircraft class there are four different data of which they contain two differen data types.
    one of which is String and the other three are in int.
    Awaiting for reply...thanks

    yes...its some objects of an array that i am trying to load back...
    erm...i'll show you the whole code maybe...
    //to reference the swing library
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    public class SetupAircraft {
         static ArrayList aircraft;
         public static void init () {
              aircraft = new ArrayList(5);
              loadAircraft(aircraft);
         //opens up another sub group while the user
         //entered 1 as his/her option in the SetupSystem
         //menu
         public static void Setup () {
              //this will create a string that is going to be displayed
              //in the input dialog box
              String menu = "  Please select an option:  \n"
                              +"----------------------------\n"
                              +"1) Add New Aircraft\n"
                              +"2) Edit Existing Aircraft\n"
                              +"3) List Aircraft\n"
                              +"4) Delete Existing Aircraft\n"
                              +"5) Save\n"
                              +"6) Return to Main Menu\n\n"
                              +"   Enter a number between 1-6\n";
              //declare a field named option for selection through menu
              int option = 0;
              //continue the loop until the user inputs the number 6
              do {
                   //error handling for the input from the menu
                   //if the input is not integer the error is caught and
                   //reassigning option to be 0
                   try {
                        option = Integer.parseInt(JOptionPane.showInputDialog(null, menu,
                                   "Setup Aircraft", JOptionPane.QUESTION_MESSAGE));
                   catch (NumberFormatException e) {
                        option = 0;
                   //determine which option the user has chosen
                   //and enters the respective section
                   switch (option) {
                        case 1: add(aircraft);
                                  break;
                        case 2: edit(aircraft);
                                  break;
                        case 3: list(aircraft);
                                  break;
                        case 4: //delete(aircraft);
                                  break;
                        case 5: save(aircraft);
                                  break;
                        case 6:     return;
                        default: JOptionPane.showMessageDialog(null, "Please enter a number between 1-6",
                                   "Alert", JOptionPane.ERROR_MESSAGE);
                                   option = 0;
              while (true);
         public static void add (ArrayList aircraft) {
              String type = "";
              int first = 0;
              int business = 0;
              int economy = 0;
              do {
                   try {
                        type = JOptionPane.showInputDialog(null,"Enter Aircraft Type", "Prompt for Type",
                        JOptionPane.QUESTION_MESSAGE);
                        try {
                             if(aircraft.contains(type)) {
                                  JOptionPane.showMessageDialog(null, type + " already exist!",
                                  "Error", JOptionPane.ERROR_MESSAGE);
                                  type = "-100";
                        catch (Exception e) {}
                        if (type=="-100");
                        else if (type.length()==0) {
                             JOptionPane.showMessageDialog(null, "Please enter an aircraft type",
                             "Error", JOptionPane.ERROR_MESSAGE);
                        else if (!(type.startsWith("-",3))) {
                             JOptionPane.showMessageDialog(null, "Please enter the aircraft type with XXX-XXX format where X is integer.",
                             "Error", JOptionPane.ERROR_MESSAGE);
                             type = "0";
                   //catch the input error that the user has produces.
                   catch (Exception e) {
                        return;
              while (!(type.startsWith("-",3)));
              //try to ask the user for the passenger's name and if the name field contains
              //no characters at all repeat the prompt for name field until the user presses
              //Cancel.
              try {
                   first = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter First Class Capacity",
                   "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
              catch (Exception e) {
                   String error = "For input string:";
                   if (e.getMessage() == "null") {
                        return;
                   else if (e.getMessage().startsWith(error)) {
                        JOptionPane.showMessageDialog(null, "Please enter only numbers",
                        "Error", JOptionPane.ERROR_MESSAGE);
              try {
                   business = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Business Class Capacity",
                   "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
              catch (Exception e) {
                   String error = "For input string:";
                   if (e.getMessage() == "null") {
                        return;
                   else if (e.getMessage().startsWith(error)) {
                        JOptionPane.showMessageDialog(null, "Please enter only numbers",
                        "Error", JOptionPane.ERROR_MESSAGE);
              try {
                   economy = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Economy Class Capacity",
                   "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
              catch (Exception e) {
                   String error = "For input string:";
                   if (e.getMessage() == "null") {
                        return;
                   else if (e.getMessage().startsWith(error)) {
                        JOptionPane.showMessageDialog(null, "Please enter only numbers",
                        "Error", JOptionPane.ERROR_MESSAGE);
              Aircraft newAircraft = new Aircraft (type, first, business, economy);
              aircraft.add(newAircraft);
              JOptionPane.showMessageDialog(null, "Aircraft Sucessfully Added",
              "Successful", JOptionPane.INFORMATION_MESSAGE);
         public static void edit (ArrayList aircraft) {
              String type = "";
              int first = 0;
              int business = 0;
              int economy = 0;
              do {
                   try {
                        type = JOptionPane.showInputDialog(null, "Enter Aircraft Type to Edit",
                        "Prompt for Type", JOptionPane.QUESTION_MESSAGE);
                        if (type.length()==0) {
                             JOptionPane.showMessageDialog(null,"Please enter an aircraft type",
                             "Error",JOptionPane.ERROR_MESSAGE);
                        else if (!(type.startsWith("-",3))) {
                             JOptionPane.showMessageDialog(null, "Please enter the aircraft type with XXX-XXX format where X is integer.",
                             "Error", JOptionPane.ERROR_MESSAGE);
                             type = "0";
                   catch (Exception e) {
                        return;
              while (!(type.startsWith("-",3)));
              try {
                   int edited = aircraft.indexOf(new UniqueAircraft(type));
                   Aircraft craft = (Aircraft)aircraft.get(edited);
                   try {
                        first = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter First Class Capacity",
                        "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
                   catch (Exception e) {
                        String error = "For input string:";
                        if (e.getMessage() == "null") {
                             return;
                        else if (e.getMessage().startsWith(error)) {
                             JOptionPane.showMessageDialog(null, "Please enter only numbers",
                             "Error", JOptionPane.ERROR_MESSAGE);
                   try {
                        business = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Business Class Capacity",
                        "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
                   catch (Exception e) {
                        String error = "For input string:";
                        if (e.getMessage() == "null") {
                             return;
                        else if (e.getMessage().startsWith(error)) {
                             JOptionPane.showMessageDialog(null, "Please enter only numbers",
                             "Error", JOptionPane.ERROR_MESSAGE);
                   try {
                        economy = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Economy Class Capacity",
                        "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
                   catch (Exception e) {
                        String error = "For input string:";
                        if (e.getMessage() == "null") {
                             return;
                        else if (e.getMessage().startsWith(error)) {
                             JOptionPane.showMessageDialog(null, "Please enter only numbers",
                             "Error", JOptionPane.ERROR_MESSAGE);
                   Aircraft newAircraft = new Aircraft (type, first, business, economy);
                   aircraft.add(newAircraft);
                   aircraft.add(newAircraft);
                   JOptionPane.showMessageDialog(null, "Successfully edited aircraft\n"+type+" to capacities\n"
                   +"First: "+first+"\n"+"Business: "+business+"\n"+"Economy: "+economy,
                   "Successful", JOptionPane.INFORMATION_MESSAGE);
              catch (Exception e) {
                   JOptionPane.showMessageDialog(null,e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
         public static void list (ArrayList aircraft) {
              JOptionPane.showMessageDialog(null, aircraft.size()+" aircraft found", "Found",JOptionPane.INFORMATION_MESSAGE);
              Object[] aircrafts;
              aircrafts = aircraft.toArray();
              for (int i=0;i<aircraft.size();i++) {
                   Aircraft a = (Aircraft) aircrafts;
                   JOptionPane.showMessageDialog(null, a, "Aircrafts" + (i+1), JOptionPane.INFORMATION_MESSAGE);
         public static void save (ArrayList aircraft) {
              try {
                   FileOutputStream fileout = new FileOutputStream(".\\Data\\Aircraft.bin");
                   ObjectOutputStream objectout = new ObjectOutputStream(fileout);
                   Object[] aircrafts;
                   aircrafts = aircraft.toArray();
                   objectout.writeObject(aircrafts);
                   objectout.close();
                   fileout.close();
                   JOptionPane.showMessageDialog(null,aircraft.size()+" aircrafts saved", "Sucessful", JOptionPane.INFORMATION_MESSAGE);
              catch (IOException e) {
                   JOptionPane.showMessageDialog(null,e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
         public static void loadAircraft (ArrayList aircraft) {
              try {
                   FileInputStream filein = new FileInputStream(".\\Data\\Aircraft.bin");
                   ObjectInputStream objectin = new ObjectInputStream(filein);
                   Aircraft craft = null;
                   while ((craft=(Aircraft)objectin.readObject())!=null) {
                        aircraft.add(craft);
                   objectin.close();
                   filein.close();
              catch (Exception e) {
                   JOptionPane.showMessageDialog(null,e.toString());
                   e.printStackTrace();
    i think thats a bit too long..but it would explain what i am trying to save...its linking to the class Aircraft tho...
    thanks...i appreciate your help...

  • Help with arrays...Please Help

    Hello,
    Iam trying to make a library system. I have three classes, one for the GUI, User class, and Users class. User class instantiates an object with all the relevant data like, Name, Age, Address, etc. The Users class contains a array of User Objects.
    With this program I have to be able to create users, display users and delete users. The problem Iam having is displaying them. (I think I correctly store the User Objectsin the array, and Iam having problems retreiving them). The thing is when I run the program I don't get any exception errors, just nothing gets displayed!
    Here is part of my code:
    public class Users {
    //declaring variables
    public Users (){
    initialiseArray();
    public void initialiseArray(){
    userArray = new User [50];
    // This method first checks to see if there is enough room for a new
    // user object. If there is the object is added to the array, if there is'nt
    // Then method expandUserArray is called to make room for the user
    public void addUser( User user)
    if (userArraySize == userArray.length) {
    expandUserArray();
    userArray[userArraySize] = user;
    userArraySize++;
    // In this method first the user is searched for in the array, if found
    // Then method decreaseUserArray is called to delete the user
    public void deleteUser ( User user )
    location = 0;
    while (location < userArraySize && userArray[location] != user) {
    location++;
    if (userArray[location] == user) {
    decreaseUserArray(location);
    public void displayUsers( ){
    for (int i = 0; i < userArraySize; i++) {
    usersInformation += "\n" + (userArray.getUserName());
    usersInformation += "\t" + (userArray[i].getUserID());
    usersInformation += "\t" + (userArray[i].getUserAddress());
    public String getUserInformation(){
    //usersInformation = userInformation.toString();
    return usersInformation;
    // The User is deleted by shifting all the above users one place down
    private void decreaseUserArray(int loc)
    userArray[loc] = userArray[userArraySize - 1];
    userArray[userArraySize - 1] = null;
    userArraySize--;
    // This method increase the size of the array by 50%
    private void expandUserArray( )
    int newSize = (int) (userArray.length * increasePercentage);
    User newUserArray[] = new User[newSize];
    for (int i = 0; i < userArray.length; i++) {
    newUserArray[i] = userArray[i];
    userArray = newUserArray;
    Is there anything wrong with my arrays??? Here is part of my code for action performed:
    void addUserButton_actionPerformed(ActionEvent e) {
    newUserName = userNameTextField.getText();
    newUserAddress = userAdressTextField.getText();
    newUserID = Integer.parseInt ( userIDTextField.getText());
    User newUser = new User (newUserName, newUserAddress, newUserID);
    Users users = new Users();
    users.addUser(newUser);
    clearButton();
    void displayUsersButton_actionPerformed(ActionEvent e) {
    Users users = new Users();
    users.displayUsers();
    displayUsersTextArea.append (users.getUserInformation());
    void deleteUserButton_actionPerformed(ActionEvent e) {
    //Still incomplete
    Thanks for your help!

    First, PLEASE USE THE SPECIAL TOKENS FOUND AT
    http://forum.java.sun.com/faq.jsp#messageformat WHEN
    POSTING CODE!!!! Sorry about that, Iam new and I did'nt know about Special Tokens.
    As far as the problem, let me start out by asking if
    you've considered using a class that implements the
    List interface. Perhaps Vector or ArrayList would
    make a better choice since they already handle
    "growing" and "shrinking" for you.I tried using vector arrays but it got too complicated. It was very easy to add and remove objects from the vector but I never figured out how to display all the objects with all the data.
    public void displayUsers( ){
    for (int i = 0; i < userArraySize; i++) {
    usersInformation += "\n" +
    " + (userArray.getUserName());   //what is
    usersInformation?  Also, how does getUserName(),
    getUserID(), getUserAddress() know which user object
    to operate on if these are methods of userArray?
    usersInformation += "\t" +
    " + (userArray.getUserID());     //I'm guess you've
    only posted "some" of your code. 
    usersInformation += "\t" +
    " + (userArray.getUserAddress());//Try posting all
    that you have so far, and please use the special
    tokens to format your code.
    }I made a mistake while I was cutting & pasting my code. It should be for example:
    usersInformation += "\n" (userArray.getUserName());
    The comment about instanciating a new Users for each
    actionPerformed is on point. You are replacing your
    Usres with a new object each time.Yep this was the problem. I just changed the constructor, declared and
    created object of Users elsewhere.
    Thanks for your help!

  • How to Convert array of int into array of byte - please help

    I have a 2-dim array of type int and I want to convert it to an array
    of byte. How can I do that? Also, if my 2-dim int array is one dimention
    can I use typecast as in the example below?
    private byte[] getData()
    byte []buff;
    int []data = new int[5];
    //populate data[]
    buff = (byte[]) data; <---- CAN I DO THIS??????
    return buff;

    hi, I suggest you make an array of byte arrays
    --> Byte[][] and use one row for each number
    you can do 2 things,
    take each cipher of one number and put one by one in each column of the row correspondent to that number. of course it may take too much room if the int[] is too big, but that is the easiest way I think
    the other way is dividing your number into bitsets(class BitSet) with sizes of 8 bits and then you can save each bit into each column of your array. and you still have one number in each row. To put your numbers back use the same class.
    Maybe someone has an easier way, I couldnt think of any.

  • Please help, 2D Array of Vectors and Incompatible types :(

    I have a 2D array of vectors called nodeLocations but when I try and access the vector inside I get a compile error.
    My code is something like this:
    nodeLocations[j].addElement(noArc)
    My editor picks up that its a Vector and shows me addElement as an acceptable entry to put after the "." yet the compiler says:
    "addElement(java.lang.Object) in java.util.Vector cannot be applied to (int)"
    Can someone please help?
    Thank you in advance.
    also a related problem:
    I get inconvertible types (says int required) when I try and get an element from a vector stored in a 2D Array. I know that it comes out as an object and so should be cast but it does not seem to work. My code is as follows:
    else if (((int)(nodeLocations[nodeNumber][adjNodeNumber].elementAt(0))) != distance)
    I would appreciate any help anyone can give.
    Similar errors to the above two happen when
    I try a push with a Stack in a vector.
    I try to get something out of the stack inside the vector.

    The Vector class's addElement() method requires an Object parameter. It appears that you're trying to add an int to the Vector. You'll need to create an Integer object and place that into the vector (see sample below) or use the pre-release version of JDK 1.5 which provides autoboxing capabilities.
    int z = 5;
    Integer x = new Integer(z);
    nodeLocations[j].addElement(x);

  • Simple array comparison not working. Please HELP!

    I have been struggling to solve this problem for a few days now, and I'm slowly losing my mind.
    I am in Adobe Acrobat 10.
    I have a group of button fields called: btn0, btn1, btn2, etc.
    I have a group of text fields called: txt0, txt1, txt2, etc.
    I have a script that takes the value of txt0 and makes it the caption for btn0, and so on.
    I have a script that sets the MouseUp action of btn0 to setFocus to txt0, and so on.
    These scripts work fine.
    I have a script that takes the values of all the txt fields and puts them in an array, and sorts it.
    I have a script that takes the array[0] item and makes it the caption for btn0, and so on (alphabetizing my list of buttons).
    Those scripts work fine.
    I am trying to compare the value of the array[0] item to each of the txt fields to find the match, and then set the MouseUp action of btn0 to setFocus to the matching txt field, and so on (so my alphabetized list points to the correct locations).
    This is where I'm at a loss.
    Here is what I have:
    //specified the txt fields
    var txt0 = this.getField("Z name");
    var txt1 = this.getField("A name");
    //etc.
    //put their values into an array called rxArray
    var rxArray = [txt0.value, txt1.value]; //etc.
    //sorted the array
    rxArray.sort();
    //set the captions equal to the sorted array items
    for (var i = 0; i < 5; i++) {
        var b = ("btn" + i);
        this.getField(b).buttonSetCaption(rxArray[i]); //works fine; alphabetizes the list of buttons
        //below is what goes wrong
        for(var x = 0; x < 5; x++) {
            var r = ("txt" + x);
            if(rxArray[i] == r.value){
                var s = (r + ".setFocus();");
                this.getField(b).setAction("MouseUp", s);
    //end
    Here is what I know:
    The alphabetizing and labeling works fine, but the buttons' MouseUp scripts don't work at all. Nothing happens.
    If I change the following piece of the above script:
            if(rxArray[i] == r.value){
                var s = (r + ".setFocus();");
                this.getField(b).setAction("MouseUp", s);
    To this:
            if(rxArray[i] == txt1.value){
                var s = (r + ".setFocus();");
                this.getField(b).setAction("MouseUp", s);
    Because rxArray[0] does equal the value of txt1 ("A name"), then the MouseUp script for btn0 gets set to:
    txt4.setFocus();
    So I know that, each time the nested loop runs, the if statement is true, and the setFocus script updates. Until the end of the loop, leaving the setFocus as the last item run. So why doesn't my script work? It should only update the setFocus script IF the array item matches the txt field, and should set it to THAT txt field.
    Please please help. I know I'm missing something simple in there somewhere.

    @Try67:
    That's a good question. I was running into some other issues and have revamped my code. Here is what I have in my test file:
    A list of five buttons and a list of five text fields. One additional button that sets the focus to the next empty text field to add a new item, and two additional buttons, one that sorts my list alphabetically, and one that unsorts it.
    with the following field names
    The sort button calls function sortName and the unsort calls function sortNumber (the order of entry).
    Here are those scripts in final form:
    function sortName() {
    //first reset the captions for the buttons to blank
    for (var a = 0; a < 5; a++) {
        var b = ("btn" + a);
        this.getField(b).buttonSetCaption("");
    var txt0 = this.getField("t0");
    var txt1 = this.getField("t1");
    var txt2 = this.getField("t2");
    var txt3 = this.getField("t3");
    var txt4 = this.getField("t4");
    var rxArray = [txt0.value, txt1.value, txt2.value, txt3.value, txt4.value];
    for(var m = rxArray.length - 1; m > -1; m--){
        if(rxArray[m] == ""){
            rxArray.splice(m, 1);
    rxArray.sort();
    var newArray = [txt0, txt1, txt2, txt3, txt4];
    for(var n = newArray.length - 1; n > -1; n--){
        if(newArray[n].value == ""){
            newArray.splice(n, 1);
    for (var i = 0; i < rxArray.length; i++) {
        var b = ("btn" + i);
        this.getField(b).buttonSetCaption(rxArray[i]);
        for (var x = 0; x < newArray.length; x++) {
            if(rxArray[i] == newArray[x].value){
                var s = ("this.getField('" + newArray[x].name + "').setFocus();");
                this.getField(b).setAction("MouseUp", s);
    //end
    function sortNumber() {
    var txt0 = this.getField("t0");
    var txt1 = this.getField("t1");
    var txt2 = this.getField("t2");
    var txt3 = this.getField("t3");
    var txt4 = this.getField("t4");
    var newArray = [txt0, txt1, txt2, txt3, txt4];
    for (var x = 0; x < newArray.length; x++) {
        var b = ("btn" + x);
        this.getField(b).buttonSetCaption(newArray[x].value);
        var s = ("this.getField('" + newArray[x].name + "').setFocus();");
        this.getField(b).setAction("MouseUp", s);
    //end
    As you can see, I've used the array lengths rather than fixed numbers, except when clearing the button values. I use a number there because there is no array to reference and didn't feel like making an array just for that. The number of buttons won't change.
    I've also added in a splice() method to remove the blank entries from my arrays when appropriate (making using the array length even more important).
    The result of the sort is:
    The only quirk I've found in all this is with the Add New button, which calls function addNew, which is:
    function addNew() {
    var txt0 = this.getField("t0");
    var txt1 = this.getField("t1");
    var txt2 = this.getField("t2");
    var txt3 = this.getField("t3");
    var txt4 = this.getField("t4");
    var newArray = [txt0, txt1, txt2, txt3, txt4];
    for (var i =  newArray.length - 1; i > -1 ; i--) {
        if (newArray[i].value == "") {
            newArray[i].setFocus();
    //end
    For this, I would have though that running through the array from start to finish looking for the first empty text field and setting the focus to it would have been correct. But that resulted in the last empty text field being focused. So I reversed the for loop to run finish to start, and the result was that the first empty field was focused. Not sure why that is...

  • ARRAY and records at multiple level ? please help

    Hi experts!!
    I am struck up with a problem. If u can please help me.
    I need a structure of this type.
    create type GRADE as object(
    grade varchar2(30)
    / -- works fine , creates
    create type GRADE_ARRAY as VARRAY(10) of GRADE;
    / -- works fine and creates
    create type SPECIES as object
    Species_number number,
    array_of_grade GRADE_ARRAY
    / works fine
    create type SPECIES_ARRAY as VARRAY(20) of SPECIES;
    -- error comes here.. Can not have multiple level..type error
    and so can not go ahead. In fect I wanted to use next level also. like this.
    The next command remains my dream only then because I could not create the SPECIES ARRAY it self..
    create type TIMBER as object
    timber_mark varchar2(6),
    no_species number,
    array_of_species(20) SPECIES_ARRAY
    the problem is for multiple level ARRAY AND RECORD/object combination..
    I tried with OBJECT AND VARRAY it does only for one level.. not even two level.
    my Mail ID:
    [email protected]
    Thanks and Regards..
    Virendra chauhan

    I think multi-level collections was first implemented in 9.2. You failed to mention what version of the DB you are using.

  • Creating an Array of external JPGs, please help.

    So what I want to do is load up external JPGs into an Array of MovieClips, and then go to the main onEnterFrame function. My code is below:
    var imageLoader:Loader = new Loader();
    var imageArray:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i] = new MovieClip();
            imageArray[i].addChild(imageLoader);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    I tried adding an Event.COMPLETE function I found:
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[i] = new MovieClip();
         imageArray[i].addChild(image);
    Unfortunately, I usually only ended up with 1 or 0 images, and errors. I can't seem to properly pass the i
    value, so that's a big problem because the order the images go is key to my program.
    Please help me get this working so my image gallery can work, thanks!

    So the problem is that you want them in the array in the same sequence am I right on this?
    See the updated code:
    var imageArray:Array = new Array();
    var imageLoader:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            var imageLoader[i] = new Loader();
            imageArray[i] = new MovieClip();
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i].addChild(imageLoader[i]);
            //imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    /* function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[index].addChild(image);
    In this case you can not track whether an image is loaded or not. It is the most simplest way of doing this. If your images are not coming from dynamic sources and are fixed in number and position you can use this method also.

  • How to create an array - Please help

    Hello. I have been trying to build a dynamic menu. According to different user role, they would have different access options to use the form. Now, I need to create a dynamic menu to display the menu options according to their user role. Somebody told me I can use an array, but I am not sure how to achieve this, and how to display the menu to user. Please help me. Thank you.

    Hi
    Arrays in Form are implemented through Record Groups. However you can enable and disable a menu item throught database roles.
    For more infor please refer Oracle Documentation.
    HTH
    Arvind Balaraman
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by scsyim:
    Hello. I have been trying to build a dynamic menu. According to different user role, they would have different access options to use the form. Now, I need to create a dynamic menu to display the menu options according to their user role. Somebody told me I can use an array, but I am not sure how to achieve this, and how to display the menu to user. Please help me. Thank you.<HR></BLOCKQUOTE>
    null

  • Parse into array using JDOM! please help

    hey,
    i've managed to parse an xml document using JDOM
    i[b] need to be able to parse it and store the text (the value of each node) into an array, and then insert into db etc.
    the problem is with the recursive function listChildren which calls itself... can someone tell me where do i insert the block of code such that i can store it into an array of string.
    here's the code:
    public static void parse(String stock) throws SQLException
    SAXBuilder builder = new SAXBuilder();
    Reader r = new StringReader(stock);
    Document doc = builder.build(r);
    Element root = doc.getRootElement();
    listChildren(root, 0);
    public static void listChildren(Element current, int depth) throws Exception
    String nodes = current.getName();
    System.out.println(nodes + " : " + current.getText());
    List children = current.getChildren();
    Iterator iterator = children.iterator();
    while(iterator.hasNext())
    Element child = (Element) iterator.next();
    listChildren(child, depth+1);
    i'm looking for something like:
    a=current.getText();
    but i donno where to include this line of code, please help
    cheers,
    Shivek Sachdev

    hi, I suggest you make an array of byte arrays
    --> Byte[][] and use one row for each number
    you can do 2 things,
    take each cipher of one number and put one by one in each column of the row correspondent to that number. of course it may take too much room if the int[] is too big, but that is the easiest way I think
    the other way is dividing your number into bitsets(class BitSet) with sizes of 8 bits and then you can save each bit into each column of your array. and you still have one number in each row. To put your numbers back use the same class.
    Maybe someone has an easier way, I couldnt think of any.

  • Problem with array size...PLEASE HELP

    hi...
    I want to keep putting the Strings that user inputs, in an array. I don't know how many of them there are, and I don't want to define a big array like :
    String myArray[]= String [1000];
    what am I suppose to do?
    PLEASE HELP...!
    Thanks

    Use a Vector or an ArrayList instead of a straight array.

  • Array of CreditCard objects - PLEASE HELP!

    My situation is this: I need to create an array of CreditCard objects. The problem is that when I try to invoke the methods getName, getNumber, or getLimit, the compiler recognizes the array (cardholders) as a variable.
    My coding is this.
    for(int i=0;fileInput.hasNext();i++)
         CreditCard[] cardholders = new CreditCard[records];
         int cardNum = Integer.parseInt(fileInput.next());
         String cardName = fileInput.nextLine();
         double cardLimit = Double.parseDouble(fileInput.nextLine());
         cardholders[i] = new CreditCard(cardNum, cardName, cardLimit);
    But when I try to access a CreditCard object, through cardholders[4] (for example), the error cannot find symbol appears. PLEASE HELP ITS DRIVING ME CRAZY.
    THANKS

    You are lacking basic Java knowledge, micksabox. The following tutorial is on Arrays in Java. The one after on the Java Collections Framework, you might want to learn about as the better solution for working with sets and lists of objects in Java.
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • Absolute Distinct count in Array -----Please help me out

    I'm running out of time and i have no clues to solve it.......can you please help me on it....
    The Absolute Distinct Count on Sorted Array is the count of
    distinct absolute values of elements of the array.
    For example, for the array.
    *[-5, -3, -1, 0, 3, 6]*
    the absolute distinct count is 5, because there is 5 distinct
    absolute values:
    *0, 1, 3, 5, 6*
    Write a function that computes the absolute distinct count
    of a given array.

    No, above code wouldn't work. Though it will give distinct count, but not absolute distinct count.
    Code to get absolute distinct count of elements in an array:
         public static void main(String args[]){
              int[] values = { -5, -3, -1, 0, 3, 6 };
              List<Integer> list=new ArrayList<Integer>();
              int tempVal=0;
              for(int val : values){
                   tempVal=Math.abs(val);
                   if(!list.contains(tempVal)){
                        list.add(tempVal);
              System.out.println("Absolute distinct count: "+list.size());
              System.out.println("Absolute distinct elements: "+list.toString());                    
         }Thanks,
    Mrityunjoy

  • Please help---merge function for two arrays.

    I am trying to create a merge function that merges two sorted arrays into a third array. I know what I am supposed to do, at least in theory, but I have been completely unsuccessful with actually getting the code to work. Since it is private, you can't directly access the arrays, you have to just reference them. could someone please help me out.
    import java.io.*;
    class OrdArray
    private long[] a;
    private int nElms;
    public OrdArray(int max)
    a = new long[max];
    nElms = 0;
    public int size()
    { return nElms;}
    public int find(long searchKey)
    int lowerBound = 0;
    int upperBound = nElms-1;
    int curIn;
    while(true)
    curIn = (lowerBound + upperBound) / 2;
    if(a[curIn]==searchKey)
    return curIn;
    else if (lowerBound > upperBound)
    return nElms;
    else
    if(a[curIn] < searchKey)
    lowerBound = curIn + 1;
    else
    upperBound = curIn - 1;
    public void insert(long value)
    int j;
    for(j=0; j<nElms; j++)
    if(a[j] > value)
    break;
    for(int k=nElms; k>j; k--)
    a[k] = a[k-1];
    a[j] = value;
    nElms++;
    public boolean delete(long value)
    int j = find(value);
    if(j==nElms)
    return false;
    else
    for(int k=j; k<nElms; k++)
    a[k] = a[k+1];
    nElms--;
    return true;
    public void display()
    for(int j=0; j<nElms; j++)
    System.out.print(a[j] + " ");
    System.out.println("");
    public void merge(OrdArray array, OrdArray array1)
    }//this is the start of the merge function. I am stuck and not real sure where to go from here.
    public long getElm(int index)
    return a[index];
    }//end class OrdArray
    class OrderedApp
    public static void main(String[]args)
    int maxSize = 100;
    OrdArray arr, arr1, arr2;
    arr = new OrdArray(maxSize);
    arr1 = new OrdArray(maxSize);
    arr2 = new OrdArray(maxSize);
    arr.insert(77);
    arr.insert(99);
    arr.insert(44);
    arr.insert(55);
    arr.insert(22);
    arr1.insert(88);
    arr1.insert(11);
    arr1.insert(00);
    arr1.insert(66);
    arr1.insert(33);
    arr2.merge(arr, arr1);
    arr.display();
    System.out.println("--------------------");
    arr1.display();
    System.out.println("--------------------");
    arr2.display();
    }

    If I use ArrayList<Long>, would I have to change private long[]a to ArrayList<long>, cause if so, I am not able to do that.
    I am supposed to add a merge() method to megre the two source arrays into an ordered destination array.
    public void merge(OrdArray array, OrdArray array1)
    mergeSize = array.nElems + array1.nElems;
    int i = 0;
    int j = 0;
    int k = 0;
    while (i = 0; i < array.nElems; i++) {
              if {array.getElm(i) < array1.getElm(j)
                                                              //how do you move to the next set of values
                                                              //and to move which variables are incremented
                                                              //how do you test if the flush loop should be      called, hint if( == )
                   while (j = mergeSize - array.nElems; j <= mergeSize; j++) { 
                                   this.a[j] = array1.a;
    //again how do you move to next value and placeholder
         //which indices are incremented
    //copy/paste and change the variables for the other value being smaller
    public long getElm(int index)
    return a[index];
    this is all I have started, but i don't really understand all the comments because I haven't used java in a long time. Like I said, I understand what needs to be done and what order to do it in, but getting the code down to do that is really rough

  • Please help/Array sorting

    Please , people help.. I am novice in the Java programming and working on the following problem right now.: Using a single-subscripted array need an applet that inputs 5 numbers, each of which betwee 10 and 100, inclusive. As each number is read,display it only if it is not a duplicate of a number already read. Have to provide for the "worst case" in which all 5 numbers are different . Need a smallest possible array to solve this problem.. Please help. Sitting here and can not do anything abt it..Need code..Sincerely A.

    Have you attempted to do anything at all? Why should
    we help you pass a class so that you can be dead
    weight on our development projects later?this is genius! amen.

Maybe you are looking for