Handling arrays with objects

well i have 2 classes a driver and a object creator....
i create an object with 4 arrays inside
the arrays are user, mail, password, diskspace
i need to make a sorting method inside my class so the arrays are displayed in alphabetical order but i just dont know how i can make it... here i post everything i have done
import java.io.*;
public class FinalDriver{
    public static void main (String[] args) throws IOException{
        BufferedReader stdIn = new BufferedReader (new InputStreamReader (System.in));       
        PrintWriter stdOut = new PrintWriter(System.out, true);       
        char option;
        boolean flag;       
        int count = 0;
        FinalClass accounts = new FinalClass();
        do{
            menu();
            option = stdIn.readLine().toUpperCase().charAt(0);
            flag = designation(option, accounts, count);
        while (!flag);
        stdOut.println("Finished");   
        public static void menu(){
        PrintWriter stdOut = new PrintWriter(System.out, true);
        stdOut.println ("***********************");
        stdOut.println ("*    E-mail Service   *");
        stdOut.println ("*---------------------*");
        stdOut.println ("*                     *");
        stdOut.println ("*  A) Add new user    *");
        stdOut.println ("*  B) Display stats.  *");
        stdOut.println ("*  C) Sort by name    *");
        stdOut.println ("*  *) Exit            *");
        stdOut.println ("*                     *");
        stdOut.println ("*---Choose a letter---*");           
        stdOut.println ("***********************");   
        public static boolean designation (char option, FinalClass accounts, int count) throws IOException{
            PrintWriter stdOut = new PrintWriter(System.out, true);
        switch (option){
            case 'A':{
                newUser(accounts , count);
                return false;
            case 'B':{
                displayStats(count, accounts);
                return false;
            case 'C':{
                sortInfo(count, accounts);
                return false;
            case '*':{
                return true;
            default:{
                stdOut.println("Invalid input");   
                return false;
        public static void newUser(FinalClass accounts, int count) throws IOException{
            BufferedReader stdIn = new BufferedReader (new InputStreamReader (System.in));
            PrintWriter stdOut = new PrintWriter(System.out, true);
            RandomStringUtils randomPassword = new RandomStringUtils();
            String name, password, email;
            double diskSpace;
            char nameChar, passChar;
            stdOut.println("You have selected new user");
            stdOut.println("What will the username be?");
            name = stdIn.readLine();
            nameChar= name.charAt(0);
            while(nameChar != '*'){           
                stdOut.println("Do tou want to create the password?");
                passChar= stdIn.readLine().toUpperCase().charAt(0);
                if(passChar == 'Y')
                    password= stdIn.readLine();
                else
                    password= passwordMethod(randomPassword);   
        stdOut.println("What will the email be?");
        email= stdIn.readLine();
        stdOut.println("how much disk space is used?");
        diskSpace= Double.parseDouble(stdIn.readLine());
        accounts.newUser(name, password, email, diskSpace, count);
        stdOut.println("What will the username be?");
        name = stdIn.readLine();
        nameChar= name.charAt(0);
        count = count + 1;
        public static void displayStats(int count, FinalClass accounts){
            PrintWriter stdOut = new PrintWriter(System.out, true);
        stdOut.println("You have chosen the Display Statistics option");
        public static void sortInfo(int count, FinalClass accounts){
            PrintWriter stdOut = new PrintWriter(System.out, true);
        stdOut.println("You have chosen the Sort Information option");
        accounts.printString(count, accounts);   
        public static String passwordMethod(RandomStringUtils randomPassword){
            String password;
            password = randomPassword.randomAlphanumeric(8);
            System.out.println("yor password is: "+ password);
            return password;
public class FinalClass
   private String [] user = new String[100];
   private String [] mail = new String[100];
   private String [] password = new String[100];
   private double [] diskSpace = new double[100];
   private int count;
   public FinalClass(){
      for(count= 0; count<100; count =count +1){
          user[count]= "-1";
          mail[count]= "-1";
          password[count]= "-1";
          diskSpace[count]= -1;
   public void newUser(String tempName, String tempPassword, String tempEmail, double tempDiskSpace, int counting){
              user[counting]= tempName;
              password[counting]=tempPassword;
              mail[counting]=tempEmail;
              diskSpace[counting]=tempDiskSpace;
   public void printString (int count, FinalClass accounts){
       for(int i = 0; count > i; i = i + 1){
           System.out.print(user[i] + "     ");
           System.out.print(mail[i] + "     ");
           System.out.print(password[i] + "     ");
           System.out.println(diskSpace[i] + "     ");

a friend of mine explained me that -1 is returned if the first value is bigger than the second 0 if they are the same and 1 if the second is bigger( bigger meaning in ascci)
then, i need to do a while loop with a for inside that leads to an if statment.. am i right?
public void printString (int count, FinalClass accounts){
        boolean flag = true;
        String tempString;
        double tempDouble;
        int intFlag;
        while (flag){
             flag = false;
             for(int i = 0; count > i ; i = i + 1){
                  intFlag = user.compareToIgnoreCase(user[i+1]);
               if (-1){
               else{
     }i just dont know what to put in the if statmente                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to initialize the array with object?

    Here is type I have.
    CREATE OR REPLACE TYPE SYSADM.AP_COMMENT_TYPE AS OBJECT
    BU_AP VARCHAR2(5),
    VOUCHER VARCHAR2(10),
    V_LINE INTEGER,
    USERID VARCHAR2(20),
    COMMENT_DTTM DATE,
    COMMENT VARCHAR2(254)
    CREATE OR REPLACE TYPE SYSADM.AP_COMMENT_COLL AS VARRAY(1000) OF SYSADM.AP_COMMENT_TYPE;
    Then I created a procedure to grab some data.
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed
    FROM ps_fas_ap_comment
    WHERE business_unit = voucher_comment (i).bu_ap
    AND voucher_id = voucher_comment (i).voucher;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed
    FROM ps_fas_ap_comment
    WHERE business_unit = voucher_comment (i).bu_ap
    AND voucher_id = voucher_comment (i).voucher
    AND voucher_line_num = voucher_comment (i).v_line;
    BEGIN
    voucher_comment (1) := ap_comment_type (' ', ' ', 0, ' ', '', ' ');
    --voucher_comment (1) := ap_comment_type (null, null, null, null, null,null);
    IF voucher_comment (i).v_line = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              voucher_comment.EXTEND;
    voucher_comment (i) :=
    ap_comment_type (v_bu_in,
    v_voucher_in,
    v_line_num,
    v_userid,
    TO_DATE (TO_CHAR (SYSDATE,
    'DD-MON-YYYY HH24:MI:SS'
    'DD-MON-YYYY HH24:MI:SS'
    v_comments
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.EXTEND;
    voucher_comment (i) :=
    ap_comment_type (v_bu_in,
    v_voucher_in,
    v_line_num,
    v_userid,
    TO_DATE (TO_CHAR (SYSDATE,
    'DD-MON-YYYY HH24:MI:SS'
    'DD-MON-YYYY HH24:MI:SS'
    v_comments
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;
    But when I tried to test the procedure, got error: ORA-06531: Reference to uninitialized collection. Does anyone have experience of handling array with object?
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL;
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 1, 'KEHE', O_voucher_comment);
    end;

    Thanks for that. I changed it a little bit, but when i ran this script, got ORA-06532: Subscript outside of limit.
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL := sysadm.ap_comment_coll(null);
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 0, 'KEHE', O_voucher_comment);
    end;
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in
    AND voucher_line_num = v_line_in;
    BEGIN
    --voucher_comment() := SYSADM.ap_comment_type (NULL, NULL, NULL, NULL, NULL, NULL);
    --' ', ' ', 0, ' ', '', ' ' sysadm.ap_comment_coll
    voucher_comment := sysadm.ap_comment_coll(null);
    IF v_line_in = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              if i > 1
              then
                   voucher_comment.EXTEND;
              end if;
    voucher_comment (i) := ap_comment_type (v_bu_in,
    v_voucher_in, v_line_num, v_userid,
    TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), v_comments );
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.extend(6);
    voucher_comment (i) := ap_comment_type (v_bu_in, v_voucher_in, v_line_num, v_userid, TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS' ), 'DD-MON-YYYY HH24:MI:SS'), v_comments);
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;

  • Populating a dynamic array with objects and managing it in runtime.

    So I'm another stuck firstyear. I'll try and make my question compact. I'm using Flash CS6 and have drawn an animated character on the stage that consists of separate parts that are animated and its head is a separate class/symbol entirely because it has not only animation, but a state switch timeline as well. This said Head extends the Main that is the character MovieClip.
    I am using a dynamic array to store and .push and .splice objects of another class that would collide with this said Head.
    I also discovered the super() function that is implicitly called as the constructor of the parent in any child class that extends the parent, in this case Head extends Main. The issue is that my collidable object array is populated within the main, within the function that spawns every next collidable object with a TimerEvent. This said function then gets called twice due to the super() call.
    I have tried putting this super() call into an impossible statement in my child class, but it doesn't change a thing, and it was said that this method is unsafe so I don't even know if it should be working.
    However what confuses me the most is when I trace() the .length of my collidable object array at the end of that function. As I said earlier, the original function both spawns an object after a period of Timer(1000) and adds it to the stage as well as adds the object onto the object array, but the super() constructor only duplicates the length call and a creates a copy of the object on the stage, but it does not add the second copy of the object onto the array. The trace() output goes on like so:
    1
    1
    2
    2
    3
    3
    4
    4
    etc.
    I wonder why and I'm really stumped by this.
    Here is the code in question:
    public class Main extends MovieClip {
                        public var nicesnowflake: fallingsnow;
                        var nicesnowflakespawntimer: Timer = new Timer(1000);
                        public var nicesnowflakearray: Array = new Array();
                        public function Main() {
                                  nicesnowflakespawntimer.addEventListener(TimerEvent.TIMER, nicesnowflakespawn);
                                  nicesnowflakespawntimer.start();
                        public function nicesnowflakespawn(event:TimerEvent) : void {
                                  nicesnowflake = new fallingsnow;
                                  nicesnowflake.x = Math.random()* stage.stageWidth;
                                  nicesnowflake.y = - stage.stageHeight + 100;
                                  nicesnowflakearray.push(nicesnowflake);
                                  stage.addChild(nicesnowflake);
                                  trace(nicesnowflakearray.length);
                                  for (var i:Number = 0; i < nicesnowflakearray.length; i++){
                                            nicesnowflakearray[i].addEventListener(Event.ENTER_FRAME, snowhit);
                        public function snowhit(event:Event) : void {
                                  if (nicesnowflakearray[0].y >= 460){
                                            if (nicesnowflakearray[0].y == stage.stageHeight) {
                                            nicesnowflakearray.splice(nicesnowflakearray.indexOf(nicesnowflake), 1);
                                  //if (this.hitTestObject(nicesnowflake)){
                                            //trace("hit");
    I am also fiddling with the collision, but I believe that it would sort itself out when I deal with the array pop and depop properly. However I'm pasting it anyway in case the issue is subtly hidden somewhere I'm not looking for it. And here is the child class:
    public class Head extends Main {
                        public function Head(){
                                  if (false){
                                            super();
                                  this.stop();
    So like what happens at the moment is that the array gets populated by the first object that spawns, but there is two objects on the stage, then when the objects reach stage.460y mark the array splices() the one object away and displays an error:
    "#1010: A term is undefined and has no properties.
              at Main/snowhit()"
    then when the next object spawns, it repeats the process. Why does it trace the array.length as "1, 1, 2, 2, 3, 3, 4, 4, 5, 5, etc" until the despawn point and then goes on to display an error and then starts from 1 again, because if the array length is more than one object at the time when the first object of the array gets spliced away, shouldn't it go on as usual, since there are other objects in the array?
    Thank you very much to whomever will read this through.

    There are multiple problems:
    1. You should add eventlisteners for your objects only once, but you add eventlisteners every time your timer runs to all of your snowflakes, again and again:
                                  for (var i:Number = 0; i < nicesnowflakearray.length; i++){
                                            nicesnowflakearray[i].addEventListener(Event.ENTER_FRAME, snowhit);
    change it to
    nicesnowflake.addEventListener(Event.ENTER_FRAME, snowhit);
    I don`t see why its even necessary to employ this snowflakearray, it would be much straight forward if you simply let the snowflakes take care of themselves.
    2. Then you have to change your enterframe function accordingly
    public function snowhit(event:Event) : void {
                                  if (e.currentTarget.y >= 460){
                                            if (e.currentTarget.y == stage.stageHeight) {
                                            e.currentTarget.removeEventlistener(Event.ENTER_FRAME, snowhit);
                                            removeChild(e.currentTarget);
    3.
                                  //if (this.hitTestObject(nicesnowflake)){
                                            //trace("hit");
    since "this" is a reference to the Main class (root) it surely won`t function as you intend it to.
                                  if (false){
                                            super();
    makes no sense to use a condition that can never be true

  • Handling Arrays with Students Grades

    Can anyone help!
    I am traying to compile program Grade2 which processes student assignment marks to determine how many students obtained each of possible grades: 1 to 5. The user enters each grade as an integer and to mark the end of the data stream a 0 or negative number. One should use suitable array to hold the numbers of students with each grade.
    This is what I compiled so far:
    import java.io.*;
    class Grade2
         public static void main(String[]args)
         throws IOException
              int grade2, count[];
         System.out.println ("Input a grade");
              grade2=Course_io.readInt();
              for (int i=0; i<5; i++)
              while (grade2>0)
                   if (grade2==1)
                        count[0]=1;
                   else if (grade2==2)
                        count[1]=2;
                   else if (grade2==3)
                        count[2]=3;
                   else if (grade2==4)
                        count[3]=4;
                   else if (grade2==5)
                        count[4]=5;
                   else if (grade2>5)
                        System.out.println("Enter correct grade");
         System.out.println ("Input a grade");
                   grade2=Course_io.readInt();
         System.out.println("The result is "+count[0]);
         System.out.println("The result is "+count[1]);
         System.out.println("The result is "+count[2]);
         System.out.println("The result is "+count[3]);
         System.out.println("The result is "+count[4]);
    When compiling this program shows two errors: refering to: grade2=Course__io.read.Int();
    I do not know where I am doing wrong?
    emni

    Dear Joni Salonen,
    Thank you for last reply, it was a error of capital letter G for grades2, as you rightly noted. Now it complies fine but still does not do the task, eg I am supose to count a number of students with each grade and store them in the array, this rutine only notes array elements index for grade entered not a number of students with that grade. Please refer back to the original code and advise what to do to reflect this task. This is a repeat of the code:
    import java.io.*;
    class grade2
         public static void main(String[]args)
         throws IOException
              int grade2, count[];
              System.out.println ("Input a grade");
              grade2=Course_io.readInt();
              count = new int[5];
              for (int i=0; i<5; i++)
              while (grade2>0)
                   if (grade2==1)
                        count[0]=1;
                   else if (grade2==2)
                        count[1]=2;
                   else if (grade2==3)
                        count[2]=3;
                   else if (grade2==4)
                        count[3]=4;
                   else if (grade2==5)
                        count[4]=5;
                   else if (grade2>5)
                        System.out.println("Enter correct grade");
                   System.out.println ("Input a grade");
                   grade2=Course_io.readInt();
              System.out.println("Number of Grades no 1 is "+count[0]);
              System.out.println("Number of Grades no 2 is "+count[1]);
              System.out.println("Number of Grades no 3 is "+count[2]);
              System.out.println("Number of Grades no 4 is "+count[3]);
              System.out.println("Number of Grades no 5 is "+count[4]);
    Thanks!
    emni

  • Need Help for Array with Object

    hey there guys... am trying to complete my project which is to create a Library System. Was able to create a list to show the books available when they select the book and click a borrow button it can print out the book.
    what problem i have now is that when a student click borrow... the value how can i transfer to an array inside the object student.
    i am usin a main screen (ms) who is controlling all the functions. been trying and trying on this for very long hopefully there will be those who are able to help me out.
    my customer screen would be like this... but how can i add in the array for books borrowed
    import javax.swing.*;
    class Customer
         private String name;
         private int accNo;
         private String password;
         private double balance;
         private Books borrow[]=new Books[5];
         int borrowCount=0;
         static int customerCount=0;
         private MainScreen ms;
         Customer(String n, int no, String p, double b)
              name=n;
              accNo=no;
              password=p;
              balance=b;
              customerCount++;
              JOptionPane.showMessageDialog(null,name +" record created");
              display();
    /* Trying to Create the Array to store information
         public void setStudentBorrow(String a)
              borrow[borrowCount]=a;
              borrowCount++;
              JOptionPane.showMessageDialog(null,"Book Borrowed");
         public String getStudentBorrow()
              for(int i=0;i<borrowCount-1;i++)
              {     return borrow;     }
         public String getPassword()
         {     return password;     }
         public String getName()
         {     return name;          }
         public int getAccNo()
         {     return accNo;     }
         public double getBalance()
         {     return balance;     }
         public void setName(String n)
         {     name=n;     }
         public void setPassword(String p)
         {     password=p;     }
         public void setBalance(double b)
         {     balance=b;     }
         public void setAccNo(int no)
         {     accNo=no;     }
         public void display()
              JOptionPane.showMessageDialog(null,
              "\nCutomer Number : "+ customerCount+
              "\nName :"+name+
              "\nAccount Number: "+accNo+
              "\nBalance (RM): "+balance,"Customer record",
              JOptionPane.INFORMATION_MESSAGE     );

    Cross Post:
    http://forum.java.sun.com/thread.jspa?threadID=779224&messageID=4433689#4433689

  • Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.

    Hi,
    I have a MBP 13' Late 2011 and Yosemite 10.10.2 (14C1514).
    Until yesterday, I was using Garmin ConnectIQ SDK and all was working fine.
    Yesterday, I've updated my system with latest security updates and Xcode updates too (Version 6.2 (6C131e)).
    Since, I can't launch the ConnectIQ simulator app, I have this message in console :
    8/04/2015 15:19:04,103 mds[38]: There was an error parsing the Info.plist for the bundle at URL Info.plist -- file:///Volumes/Leto/connectiq-sdk-mac-1.1.0_2/ios/ConnectIQ.bundle/
    The data couldn’t be read because it isn’t in the correct format.
    <CFBasicHash 0x7fa64f44e9a0 [0x7fff7dfc7cf0]>{type = immutable dict, count = 2,
    entries =>
      0 : <CFString 0x7fff7df92580 [0x7fff7dfc7cf0]>{contents = "NSDebugDescription"} = <CFString 0x7fa64f44f0a0 [0x7fff7dfc7cf0]>{contents = "Unexpected character b at line 1"}
      1 : <CFString 0x7fff7df9f5e0 [0x7fff7dfc7cf0]>{contents = "kCFPropertyListOldStyleParsingError"} = Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it isn’t in the correct format." (Conversion of string failed.) UserInfo=0x7fa64f44eda0 {NSDebugDescription=Conversion of string failed.}
    I have looked at this file and it looks like a binary plist
    bplist00ß^P^V^A^B^C^D^E^F^G^H
    ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"$%&'()'+,^[\CFBundleNameWDTXcodeYDTSDKName_^P^XNSHumanReadableCopyrightZDTSDKBuild_^P^YCFBundleDevelopmentRegion_^P^OCFBundleVersi    on_^P^SBuildMachineOSBuild^DTPlatformName_^P^SCFBundlePackageType_^P^ZCFBundleShortVersionString_^P^ZCFBundleSupportedPlatforms_^P^]CFBundleInfoDictionaryVersion_^P^RCFBundleE    xecutableZDTCompiler_^P^PMinimumOSVersion_^P^RCFBundleIdentifier^UIDeviceFamily_^P^QDTPlatformVersion\DTXcodeBuild_^P^QCFBundleSignature_^P^ODTPlatformBuildYConnectIQT0611[iph    oneos8.1o^P-^@C^@o^@p^@y^@r^@i^@g^@h^@t^@ ^@©^@ ^@2^@0^@1^@5^@ ^@G^@a^@r^@m^@i^@n^@.^@ ^@A^@l^@l^@ ^@r^@i^@g^@h^@t^@s^@ ^@r^@e^@s^@e^@r^@v^@e^@d^@.V12B411RenQ1V14C109Xiphoneos    TBNDLS1.0¡#XiPhoneOSS6.0YConnectIQ_^P"com.apple.compilers.llvm.clang.1_0S8.1_^P^Tcom.garmin.ConnectIQ¡*^P^AW6A2008aT????^@^H^@7^@D^@L^@V^@q^@|^@<98>^@ª^@À^@Ï^@å^A^B^A^_^A?^AT^    A_^Ar^A<87>^A<96>^Aª^A·^AË^AÝ^Aç^Aì^Aø^BU^B\^B_^Ba^Bh^Bq^Bv^Bz^B|^B<85>^B<89>^B<93>^B¸^B¼^BÓ^BÕ^B×^Bß^@^@^@^@^@^@^B^A^@^@^@^@^@^@^@-^@^@^@^@^@^@^@^@^@^@^@^@^@^@^Bä
    I guess it is a normal format but my system seems to be unable to read binary plist ?
    I tried some stuff with plutil
    plutil -lint Info.plist
    Info.plist: Unexpected character b at line 1
    Same for convert
    plutil -convert xml1 Info.plist
    Info.plist: Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
    I also try to download a fresh version of the connectIQ SDK and no changes.
    Any idea ?
    Thanks

    Step by step, how did you arrive at seeing this agreement?

  • How to create a spidar chart (Radar chart) with an array collection object...

    Hi All,
              I need to create Spidar (Radar) chart in my application with the help of an array collection object........can any one help me ?? do i need to import any external library ???
    Please provide the required code for it .........
    Thanks in advance....

    You'll need to set the "series" property of the chart. This will be an array of BarSeries objects.
    You may also need to set the horizontalAxis and verticalAxis properties for the chart. (I forget if there are defaults for these.)

  • Table with object array data provider

    hi!
    i use the studio creator table and want to fill it with an object array data provider!
    i have an array and the getter:
      public TanData[] getTanDataArray()
            return tanDataArray;    
        }i choosed this for the data provider and in table layout i choose the dataprovider, but when i run my application there are no datas found although the array isn't empty!

    maybe this is a problem:
    i got my data from a database table and i store it in a vector.
    in the example they have a class WeekBean and they fill their array with
       WeekBean[] weeks = {
                new WeekBean(1),
                new WeekBean(2),
                new WeekBean(3),
                new WeekBean(4)
            };and i tried to do this:
        private Vector<TanData> tanDataList = new Vector();
        private TanData[] tanDataArray;
       getTanDataList().copyInto(tanDataArray);could it be that that isn't correct?

  • Creating a generic class with a constructor that takes an array of objects

    I am relatively new to java and want to build a quick utility class that can generate a Run Length Encoding of any object. The idea is to take an array of objects of type "O" and then encode a string of objects that are "equal" to each other as an integer that counts the number of such equal instances and a single copy of the instance. This has the potential to very quickly reduce the size of some objects that I want to store. I would like to implement this class as a generic.
    public class RunLengthEncoding<O> {
         private class RLEPair {
              private int length;
              private O object;
         public RunLengthEncoding(O[]) {
    }As you can see, I need to make a constructor that takes an array of type "O". Is this possible to do? I can't seem to find the right syntax for it.
    Thanks,
    Sean

    Sorry. Obvious answer:
    public RunLengthEncoding(O[] oarray) {Again, sorry for the noise.

  • Question with object arrays..

    This is my code and it doesn't seem to be working properly
    public class familymember {
    public familymember(){
    Object[] array=new Object[500];
         public static void main(String args[]) {
         familymember array2 = new familymember();
         array2.array[51] = "500";
              System.out.println( array2.array[51]);
    I get the error message
    Error : No variable array defined in class familymember.
    familymember.java line 15 array2.array[51] = "500";
    What am i doing wrong?

    array cannot be accessed from outside it's block (in this case the constructor).
    just change your code this way:
    public class familymember {
      private Object[] array; // or public or protected or whatever you want
      public familymember(){
        array=new Object[500];
      public static void main(String args[]) {
        familymember array2 = new familymember();
        array2.array[51] = "500";
        System.out.println( array2.array[51]);
    }

  • Help with working with an array of objects

    Help!
    I'm trying to make an array of objects.
    I have a class named enemy.
    I want an array of enemy's.
    enemy[] Elist = new enemy[num];
    I now have an empty array.
    My question is, How do I initialize and retrieve vars from the objects?

    To create you need a loop that for each slot in the array you create a new enemy (should be Enemy) and store it in the array.
    Do you know how to access a single element in an array? ie the syntax to do that. If not then re-read your book or notes on arrays. I'm sure it mentions it there.
    Or you can just read the code provided above.
    Message was edited by:
    flounder

  • Creating an array of objects of a class known ONLY at RUNTIME

    I have a method in a class which expects an array of objects of particular type (say A) as its only argument. I 'invoke' this method using reflection. I have the instances of the class A stored in a Vector. When I do 'toArray' on this vector, what I get back is an array of Objects and not an array of objects of A. I assign this array to the zeroth element of another Object array and pass that array as a second argument to the 'invoke' method. Of course, it throws an Exception saying - argument types mismatch. Because I am sending an array of Objects to a method expecting an array of objects of A. My problem is I don't know A until runtime. So I have to handle whatever I am getting back after doing 'toArray' on a vector as a Generic Object. I know there's another version of 'toArray' in the Vector class. But it's API documentation didn't help a lot.
    Can anybody please help me solve this problem? Any sort of hints/code snippet would be of great help.
    Does the above description makes any sense? If not, please let me know. I would try to illustrate it with a code sample.
    Thanks a lot in advance.

    Sorry, for the small typo. It is -
    clazz[] arr = (clazz [])java.lang.reflect.Array.newInstance(clazz, n);
    instead
    Thanks for the reply. I could do this. But I am
    getting a handle to the method to be 'invoke'd by
    looking at the types of the parameters its
    expecting(getParameterTypes). So I can't change it to
    accept an array of Generic Objects.
    I looked at the java.lang.reflect.Array class to do
    this. This is what I am trying to do-
    String variableName is an input coming into my
    program.
    n is the size of the array I'm trying to create.
    Class clazz = Class.forName(variableName);
    clazz[] arr = (clazz
    [])java.lang.reflect.newInstance(clazz, n);
    According to Reflection API, it should work, right?
    But compiler yells at me saying 'class clazz not
    found'.
    Any suggestions/hints/help?
    Thanks, again.

  • An array of objects

    Hi,
    I'm having trouble creating an array of objects to store data I'm reading in from a text file.
    I have created a class called mssg, and as I read each line of the textfile in, I've created a method called setMsg that I'm using to populate the mssg object I've created.
    This works fine when I use this method on a single instance of a mssg object, but when I try to use the same code on a mssg object that's part of an array, I get an exception (and one that doesn't have any friendly error text)
    mssg ms = new mssg();  //this works as expected
    mssg msgs[] = new mssg [msgCounter]; //I believe the exception relates to how I'm declaring the array of objects here, but the exception doesn't occur until I try to assign data to an element of the arrayThe lines below are where the problem becomes apparent. The first object 'ms' gets assigned its values as I'd expect, however, the line below that tries to assign values to a mssg object in the msgs array, and I get an exception immediately.
    ms.setMsg(currMsg,mDt,mTm,mDir,mData);
    msgs[currMsg].setMsg(currMsg,mDt,mTm,mDir,mData);Can anyone tell me what I'm doing wrong in terms of declaring/assigning values to an array of objects?

    It's the following error: java.lang.NullPointerException
    Full error text if I take my code out of a try/catch loop is:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at FIXparserUI.jMenuLoadActionPerformed(FIXparserUI.java:301)
            at FIXparserUI.access$100(FIXparserUI.java:20)
            at FIXparserUI$3.actionPerformed(FIXparserUI.java:129)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1170)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1211)
            at java.awt.Component.processMouseEvent(Component.java:6038)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
            at java.awt.Component.processEvent(Component.java:5803)
            at java.awt.Container.processEvent(Container.java:2058)
            at java.awt.Component.dispatchEventImpl(Component.java:4410)
            at java.awt.Container.dispatchEventImpl(Container.java:2116)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
            at java.awt.Container.dispatchEventImpl(Container.java:2102)
            at java.awt.Window.dispatchEventImpl(Window.java:2429)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)at the point that the following line of code is run:
    msgs[currMsg].setMsg(currMsg,mDt,mTm,mDir,mData);msgCounter is used to count the number of lines in the file (about 2300)
    I had hoped that what I was doing with this line:
    mssg msgs[] = new mssg [msgCounter];was create 2300 empty mssg records, ready to be populated from each line of data, however I have the feeling you're going to tell me I'm wrong.

  • Array of objects in class private data and calling overridden VIs on these objects?

    Hello
    I am developing part of an application using the actor framework and have run into problems.
    I have a several actors and will try briefly describe them and their intended functionality. All actors are started by a Controller actor and in the actor core for the controller I have the possibility to do a lot of intiliazation etc.
    Logger:
    Has a message (Send Log Message) that other actors can use to write to the log. It is supposed to take a string input and a log level (error, warning, debug etc). This message chain sends data to the actor core with a user event.
    The Actor Core of Logger is supposed to save the incoming message to a log, but should be able to do it in several different ways (file, database, email or whatever).
    Logger Output:
    Abstract class that has a dynamic dispatch vi called "Write Output" that all it's children are supposed to overwrite.
    Logger Output File
    Child of Logger Output and overwrites "Write Output" to save the string to a file on disk.
    Problem:
    I want to be able to set up the actor core for Logger once and for all but still be able to create new children of "Logger Output" and have them be handled in the Logger actor core.
    My idea was to have Logger use an array of objects as private data and initialize this array in the Controller actor core.
    In the logger actor core I could then auto index the array and use each element (each Logger Output child) and the abstract "Write Output" vi to get the correct functionality.
    HOWEVER, I cannot get this to work properly and I think I have misunderstood something or stared myself blind on this problem. I have tried 3 different methods when it comes to private data for Logger.
    1. Labview Object
    2. Array of Labview Object
    3. Array of Logger Output Object
    Of these 3 methods, I can only get the first one to work and that doesn't accomplish what I want in the end (being able to add more classes without changing private data / actor core for Logger).
    I have included 3 screenshots that show snippets of 2 of the actor cores and the private data. File names should correspond to my description above.
    The screenshot "Logger actor core.png" shows a very fast test of the 3 different methods I described above. Each of the 3 tunnel inputs to the event structure can be wired to the "Reference" input of "To More Specific Class", but only method 1 (Labview Object) works.
    If you need additional information / screenshots or whatever please ask.
    Thanks in advance
    Attachments:
    Logger ctl.PNG ‏8 KB
    Logger actor core.PNG ‏25 KB
    Controller Actor Core.PNG ‏11 KB

    Thanks for the reply and sorry for the confusing OP. It was meant as a quick test and a way to skip making 10+ screenshots .
    I updated the actor core for the Controller and Logger to be less confusing (hopefully) and attached 2 screenshots.
    I agree with you that it would be a good idea to make a message for the controller that can launch new children of the L" abstract actor, but for these tests I have just launched it the easy way (dragging it to the controller actor core).
    Both Logger Output and Logger Output File are actors and in Logger Output there is a dynamic dispatch vi called Write Output that I want to override in all its children.
    The problem is when I run the actor core of Logger (see the screenshot) only the abstract version (the one in Logger Output) of Write Output is executed, not the overridden version from Logger Output File.
    When I did the same thing with the actor cores looking like the did in my original post, then the correct overridden version got executed when I used the method with one Labview Object in private data (not any array or an array of Logger Output objects).
     EDIT: I just tried to have the Logger private data be a single Logger Output object and writing the Logger Output File to that piece of private data in the Controller and the correct Write Output override method gets called now. So apparently I have done something stupid when it comes to creating the array of Logger Output objects and writing them in the controller? The private data is in the Logger actor so I have simply right clicked and chosen "New VI for Data Member Access" and chosen "Write" for "Element of Array of Logger Output Objects".
    Attachments:
    Controller Actor core updated.PNG ‏10 KB
    Logger actor core updated.PNG ‏24 KB

  • Displaying the contents of an array of objects

    Hello All,
    My Java teacher gave us a challenge and I'm stumped. The teacher wants us to display the contents of the array in the main menthod. The original code is as follows:
    public class TestObjects
         public static void main ( String args[] )
              Thing[] thingArray = { new Thing(4), new Thing(7) };
    }I understand that the elements of the array are objects, and each one has a value assigned to it. The following code was my first attempt at a solution:
    public class TestObjects
         public static void main ( String args[] )
              Thing[] thingArray = { new Thing(4), new Thing(7) };
                                    for ( int i = 0; i < thingArray.length; i++)
                                       System.out.println( thingArray );                         
    }To which I'm given what amounts to garbage output. I learned from reading about that output that its basically displaying the memory location of the array, and the the contents of the array. There was mention of overriding or bypassing a method in System.out.println, but I don't believe that we're that far advanced yet. Any thoughts? I know I have to get at the data fields in the objects of the array, but i'm not having an easy time figuring it out. Thanks very much in advance!

    robrom78 wrote:
    public class TestObjects
         public static void main ( String args[] )
              Thing[] thingArray = { new Thing(4), new Thing(7) };
    for ( int i = 0; i < thingArray.length; i++)
    System.out.println( thingArray );                         
    Note that you're trying to print the entire array at every loop iteration. That's probably not what you meant to do.
    You probably meant to do something more like
                                 System.out.println( thingArray[i] );Also, note that the java.util.Arrays class has a toString method that might be useful.
    To which I'm given what amounts to garbage output. It's not garbage. It's the default output to toString() for arrays, which is in fact the toString() defined for java.lang.Object (and inherited by arrays).
    I learned from reading about that output that its basically displaying the memory location of the array, and the the contents of the array.It displays a default result that is vaguely related to the memory, but probably shouldn't be thought of us such. Think of it as identifying the type of object, and a value that differentiates it from other objects of the same type.
    By the way I assume you mean "+not+ the contents of the array" above. If so, that is correct.
    There was mention of overriding or bypassing a method in System.out.println, but I don't believe that we're that far advanced yet. Any thoughts? No, you don't override a method in println; actually methods don't contain other methods directly. You probably do need to override toString in Thing.
    I know I have to get at the data fields in the objects of the array, but i'm not having an easy time figuring it out. You can get to the individual objects in the array just by dereferencing it, as I showed you above.
    But I suspect that won't be sufficient. Most likely, Thing doesn't have a toString method defined. This means that you'll end up with very similar output, but it will say "Thing" instead of "[Thing" and the numbers to the right of the "@" will be different.
    You'll need to override the toString() method in Thing to get the output you want.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • I can no longer be reached at my number in iMessage

    I can no longer checked my cell number under "You can be reached by iMessage at:" but can only check my wife's number or my ME.com email.  I also cannot start new conversations from my own number.

  • Jabber Client on Samsung S3 mini (GT-I8190) cannot register on CUCM 9.1

    We have a BE6000 running with CUCM 9.1 and Desktop Phones, Windows Jabber, iPhone Jabber and iPad Jabber are all working. Now i wanted to register a the Samsung S3 mini (GT-I8190) with Android 4.1.2 and get always the message "Connection failed." - i

  • Cant sign in to use find my iphone on pc?

    This is what my computer says "iCloud has stopped responding. An error has prevented this application from working properly. Help Apple improve its products by sending us diagnostic and usage informaiton about iCloud. So I send to apple and try and r

  • Using Address..End Address Command in Script ?

    Using Address........End Address Command in Script , Is it possible to print without Name filed ? I have tried but w/o name field it is not printing   .. I liket to print like this Address paragraph Z3 Street ........................... PoBox........

  • HTML Link to iBooks

    Here is the correct syntax for linking to a specific book in the Apple iBookstore ( ###... = a 13 digit isbn number) in HTML: <a href="http://itunes.apple.com/us/book/isbn#############">On Apple iBooks</a> What is the correct syntax for linking a ser