Need help Sorting an Arraylist of type Object by Name

Hey guys this is my first time posting on this forum so hopefully i do it the right way. My problem is that i am having difficulties sorting an Array list of my type object that i created. My class has fields for Name, ID, Hrs and Hrs worked. I need to sort this Array list in descending order according to name. Name is the last name only. I have used a bubble sort like this:
public static void BubbleSort(TStudent[] x){
TStudent temp = new TStudent();
        boolean doMore = true;
        while (doMore) {
            doMore = false;
            for (int i=0; i < x.length-1; i++) {
               if (x.stuGetGPA() < x[i+1].stuGetGPA()) {
// exchange elements
temp = x[i]; x[i] = x[i+1];
x[i+1] = temp;
doMore = true;
before many time to sort an array of my class TStudent according to GPA.  This time though i tried using an Array list instead of just a simple array and i can't figure out how i would modify that to perform the same task.  Then i googled it and read about the Collections.sort function.  The only problem there is that i know i have to make my own comparator but i can't figure out how to do that either.  All of the examples of writing a comparator i could find were just using either String's or just simple Arrays of strings.  I couldn't find a good example of using an Array list of an Object.
Anyways sorry for the long explanation and any help anyone could give me would be greatly appreciated.  Thanks guys
Edited by: Brian13 on Oct 19, 2007 10:38 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

ok still having problems I have this line of code to try and all Arrays.sort
Arrays.sort(Employee, TEmployee.FirstNameComparator);Then in my class TEmployee i have
public static Comparator FirstNameComparator = new Comparator() {
    public int compare(Object employee, Object anotherEmployee) {
      String lastName1 = ((TEmployee) employee).getEmpName().toUpperCase();
      String lastName2 = ((TEmployee) anotherEmployee).getEmpName().toUpperCase();     
       return lastName1.compareTo(lastName2);
  };Here is the rundown of what i have for this. I have 2 classes. One is called TEmployee and that class holds fields for Name, ID, Hrs Worked, Hourly Rate. Then i have another class called myCompany that holds an ArrayList of type TEmployee. Then i have my main program in a Jframe.
So maybe i am putting them in the wrong spots. The code in TEmployee thats make the comparator is fine. However when i try to call Arrays.sort from class myCompany i get this
cannot find symbol
symbol: method sort (java.util.Array list<TEmployee>.java.util.Comparator
location: class java.util.Arrays
I have to put the comparator in TEmployee right because thats where my fields for Name are? Do i call the arrays.sort from my main program or do i call that from the class myCompany where my ArrayList of TEmployees are stored?
Again guys thanks for any help you could give me and if you need any code to see what else is going on just let me know.

Similar Messages

  • Need help sorting an ArrayList of strings by an in common substring

    I'm trying to sort a .csv file, which I read into an ArrayList as strings. I would like to sort by the IP address within the string. Can someone please help me figure out the best way to sort these strings by a common substring each has, which is an IP address.
    I'm pretty sure that I need to use Collections some how, but I don't know where to begin with them besides trying to look online for help. I had no luck finding any good examples, so I came here as a last resort.
    Thanks for any help provided.

    You need to write your own Comparator class. In the compare() method you substring out the two IP addresses, compare them and return appropriate value. Then you call Collections.sort() and pass your list and comparator.

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • Need help (desperately) '^_^ in writing multiple objects in a single file

    For all those Java guru out there please help me,
    I want to write a simple application that can serialize objects in a single file. Currently I know how to serialize one object in one file using the ObjectOutputStream's writeObject () method.But the problem is that if i have 10.000 objects to serialize then I will have 10.000 file in my HD. To simplify things I want to write those 10.000 objects in a single file. But I dont know how to do that, any one can help ??

    You can write any number of objects of any type into a file when you serialize them. You need to realize that once they're written to the file, they're all placed in there as type Object, so there really isn't any distinction between any of them. You don't have a file that contains only Shapes, or only Images. You write them out as Objects, and then you discover their types later as your deserialize them and read them in. You should read into the "Reflection" capabilities that all objects have. You write an Image to a file, and then a Shape, and then a Color, you can later pack these all into an ArrayList as you read them in, and when you use them discover their type using reflection.
    -Jason Thomas.

  • Need help sorting fil

    i have a brand new MuVo n200
    i need help, i put my cd's in and everyhting and i filled it with songs ans i can play them and everything, but i hate thats itssorted in ABC order. i cannot figure how to put them so it is in order by the CD or the bandname.
    please help.
    message me on aim if you want [email][email protected]][email protected][/url]

    To group the songs into albums or artist groups, I would definitely suggest putting all the tracks from each album/group in its own folder on your PC and put the folder on the muvo in just the same way as you would put a single mp3. The player (in normal play mode) will then play each folder all the way through before moving on to the next one alphabetically (or numerically, if you put numbers at the start of the folder names) and you can then use 'skip folder' to skip through to find the particular album or artist you're looking for. Play around with the shuffle modes too - you can shuffle within folders or just shuffle everything if you want.
    Tracks will normally be played alphabetically. To get them to play in order of track number, put numbers at the beginning of each file name. E.g.: file 'examplesong.mp3' would become '0_ examplesong.mp3' If you've got tonnes of songs and you're worried about it taking ages, the computer will do it for you! Click on 'my computer', then click on 'Muvo N200 media explorer'.. This shows the contents of your player. Choose a folder to reorder the songs in and click on it to display the songs. In the pictures along the top of the window, 4th from the right is an icon with a downward facing arrow and an A above a Z. Click on this, it's called 'custom sort'. You can then use the arrows at the bottom to change the order of your tracks to how you want them. Click OK, and they'll all be numbered in that order!
    For instructions on how to create folders in mediasource, read the thread in this link:
    http://forums.creative.com/creativelabs/board/message?board.id=dap&message.id=926
    I don't think you can put folders within folders in the muvo, but just the one layer really helps organisation.
    Hope that helps!
    x Flaneur
    PS- scroll down in the thread in the link: Jeremy CL was nice enough to give pictures in his instructions! If you'd like more help, type 'create folders' or something into the forum search as there's probably quite a lot of advice kicking about here!Message Edited by flaneur on 03-27-2005 :8 PM

  • Need help on how to access session object in javaBean

    Hi All,
              I am new to JSP. I have writen a java helper class which gets some data
              from a Session Bean.
              I want to use <jsp:useBean scope="session"> directive in the JSP.
              The helper class requires the reference to session Object to initialize
              itself.
              It looks like I can only pass Strings Or Basic data Type using
              <jsp:setProperty> directive. I want the helper class to initialize only
              once per session.
              I am using weblogic 4.5 and jdk 1.1.7B.
              Need help soon.
              Thanks in Advance
              Regards
              Arun
              

    Arun,
              You need only create a method on the bean and call it passing the request
              object which contains the
              session object. You need not scope to session if you don't need to as well
              ie
              <jsp:useBean id=foo class= myclass.foo scope="session">
              <%
              foo.init(reqeust);
              %>
              Harry
              Arun Kumar <[email protected]> wrote in message
              news:8itp3l$b67$[email protected]..
              > Hi All,
              > I am new to JSP. I have writen a java helper class which gets some data
              > from a Session Bean.
              >
              > I want to use <jsp:useBean scope="session"> directive in the JSP.
              > The helper class requires the reference to session Object to initialize
              > itself.
              >
              > It looks like I can only pass Strings Or Basic data Type using
              > <jsp:setProperty> directive. I want the helper class to initialize
              only
              > once per session.
              >
              > I am using weblogic 4.5 and jdk 1.1.7B.
              >
              > Need help soon.
              >
              > Thanks in Advance
              > Regards
              > Arun
              >
              >
              >
              

  • Need Help in trying to understand class objects

    I need help on understanding following problem.I have two files for that, which are as follows:
    first file
    public class Matrix extends Object {
         private int  matrixData[][];     // integer array to store integer data
         private int    rowMatrix;     // number of rows
         private int    colMatrix;     // number of columns
         public Matrix( int m, int n )
         {       /*Constructor: initializes rowMatrix and colMatrix,
              and creates a double subscripted integer array matrix
              of rowMatrix rows and colMatrixm columns. */
              rowMatrix = m;
              colMatrix = n;
              matrixData = new int[rowMatrix][colMatrix];
         public Matrix( int data[][] )
         {     /* Constructor: creates a double subscripted integer array
              and initilizes the array using values of data[][] array. */
              rowMatrix = data.length;
              colMatrix = data[0].length;
              matrixData = new int [rowMatrix][colMatrix];
              for(int i=0; i<rowMatrix; i++)
                   for(int j=0; j<colMatrix; j++)
                        matrixData[i][j] = data[i][j];
         public int getElement( int i, int j)
         {      /* returns the element at the ith row and jth column of
              this matrix. */
              return matrixData[i][j];
         public boolean setElement( int  x, int i, int j)
         {     /* sets to x the element at the ith row and jth column
              of this matrix; this method  should also check the
              consistency of i and j (i.e.,  if  i and j are in the range
              required for subscripts; only in this situation the operation
              can succeed); the method should return true if the operation
              succeeds, and should return false otherwise.
              for(i=0;i<rowMatrix;i++){
                   for(j=0;j<colMatrix;j++){
                        x = matrixData[i][j];
              if(i<rowMatrix && j<colMatrix){
                   return true;
              else{
                   return false;
         public Matrix transposeMatrix( )
         {     /*returns a reference to an object of the class Matrix,
              that contains the transpose of this matrix. */
         Verify tata;
         Matrix trans;
         //Matrix var = matrixData[rowMatrix][colMatrix];
         for(int row=0;row<rowMatrix;row++){
              for(int col=0;col<colMatrix;col++){
              matrixData[rowMatrix][colMatrix] = matrixData[colMatrix][rowMatrix];
         trans = new Matrix(matrixData);
                         return trans;
         public Matrix multipleMatrix( Matrix m )
              /*returns a reference to an object of the class Matrix,
              that contains the product of this matrix and matrix m. */
          m = new Matrix(matrixData);
              //Matrix var = matrixData[rowMatrix][colMatrix];
              for(int row=0;row<rowMatrix;row++){
                   for(int col=0;col<colMatrix;col++){
                        //trans[row][col] = getElement(row,col);
         return m;
         public int diffMatrix( Matrix m )
              /*returns the sum of the squared element-wise differences
              of this matrix and m ( reference to the formula in the description
              of assignment 5) */
         return 0;
         public String toString(  )
              /* overloads the toString in Object */
              String output = " row = " + rowMatrix + " col="+colMatrix + "\n";
              for( int i=0; i<rowMatrix; i++)
                   for( int j=0; j<colMatrix; j++)
                        output += " " + getElement(i,j) + " ";
                   output += "\n";
              return output;
    Second file
    public class Verify extends Object {
         public static void main( String args[] )
              int[][] dataA = {{1,1,1},{2,0,1},{1,2,0},{4,0,0}}; // data of A
              int[][] dataB = {{1,2,2,0},{1,0,3,0},{1,0,3,4}};   // data of B
              Matrix matrixA = new Matrix(dataA);     // matrix A
              System.out.println("Matrix A:"+matrixA);
              Matrix matrixB = new Matrix(dataB);     // matrix B
              System.out.println("Matrix B:"+matrixB);
              // Calculate the left-hand matrix
              Matrix leftFormula = (matrixA.multipleMatrix(matrixB)).transposeMatrix();
              System.out.println("Left  Side:"+leftFormula);
              // Calculate the right-hand matrix
              Matrix rightFormula = (matrixB.transposeMatrix()).multipleMatrix(matrixA.transposeMatrix());
              System.out.println("Right Side:"+rightFormula);
              // Calculate the difference between left-hand matrix and right-hand matrix
              // according to the formula in assignment description
              double diff = leftFormula.diffMatrix(rightFormula);
              if( diff < 1E-6 ) // 1E-6 is a threshold
                   System.out.println("Formula is TRUE");
              else
                   System.out.println("Formula is FALSE");
    }My basic aim is to verify the formula
    (A . B)' =B' . A' or {(A*B)tranpose = Btranspose * A transpose}Now My problem is that I have to run the verify class file and verify class file will call the matrix class and its methods when to do certain calculations (for example to find left formula it calls tranposematrix() and multipleMatrix();)
    How will I be able to get the matrix which is to be transposed in transposeMatrix method (in Matrix class)becoz in the method call there is no input for transposematrix() and only one input for multipleMatrix(matrix m).
    please peeople help me put in this.
    thanking in advance

    Please don't crosspost.
    http://forum.java.sun.com/thread.jspa?threadID=691969
    The other one is the crosspost.Okay, whatever. I'm not really concerned with which one is the original. I just view the set of threads overall as being a crosspost, and arbitrarily pick one to point others toward.
    But either way
    knightofdurham... pick one thread and post only in
    the one.Indeed. And indicate such in the other one.

  • Need help to open and look for file by name

    Hi,
            Im needing help to open a folder and look for a file (.txt) on this directory by his name ... The user ll type the partial name of file , and i need look for this file on the folder , and delete it ....
    How can i look for the file by his name ?
    Thx =)

    Hi ,
        Sry ,, let me explain again ... I ll set the name of the files in the follow order ... Name_Serial_date_chanel.sxc ..
    The user ll type the serial that he wants delete ...
    I already figured out what i need guys .. thx for the help ^^
    I used List Directory on advanced IO , to list all .. the Name is the same for all ... then i used Name_ concateneted with Serial(typed)* .. this command serial* ll list all serials equal the typed , in my case , ll exist only one , cuz its a count this serial .Then i pass the path to the delete , and its done !
    Thx ^^

  • Need help with EXS24 "read velocity range from file name"

    I am trying to import 127 drum samples to a single key using the option shown here. The option says "Map to key dropped on and read velocity range from file name". I can find no documentation in the manuals on how to do this. What is the syntax required in the file name to make this work? I need to do several of these imports. The capability is cleary there, but I need help on how the file name should be formatted. My thanks to anyone who can help.

    Hi
    Not a direct answer to your question, but if you are doing a lot of sample mapping etc, you may want to check out Redmatica's KeyMap Pro or the simpler Keymap 1:
    http://www.redmatica.com
    CCT

  • Need help with Address Book---trying to print first names first???

    I am trying to print address labels from the Address Book but the last name keeps coming up first.  Entered correctly using First and Last name boxes.  Also checked the Preferences-General and marked the box to put First names first but no luck.  Am I missing something?

    See the Address Book Preferences/General tab.  Is the the "Sort by" dropdown box set to Last Name?

  • Need help sorting 2 arrays linked by their indexes

    I have 2 arrays that have been linked by the index of both arrays. The first array has to be sorted alphabetically, so I need a way to sort the 2nd array so that the indices match up again with the first array.
    Now, I cannot change my ArrayList (i.e. TreeSet, List, etc.) since there is lots of code that would have to be changed. Here is my test code. Hopefully everyone is a fan of the television show Friends so that you can see how if I sort the firstName Array alphabetically, then I have to have the 2nd array sorted to be "linked" back to the first array based on the index. I am looking for ideas, but if you have simple code, that would be great too.
    import java.util.*;
    public class Test
         public static void main(String[] args)
              System.out.println("BEGIN TEST...");
    Test test = new Test();
    test.beginTest();
    System.out.println("\nTEST COMPLETE!");
         public Test(){}
         public void beginTest()
              ArrayList firstName = new ArrayList();
              ArrayList lastName = new ArrayList();
              //Add to firstName ArrayList
              firstName.add("Ross");
              firstName.add("Chandler");
              firstName.add("Rachel");
              firstName.add("Phoebe");
              firstName.add("Joey");
              //Add to lastName ArrayList
              lastName.add("Geller");
              lastName.add("Bing");
              lastName.add("Green");
              lastName.add("Buffay");
              lastName.add("Tribbiani");
              try
                   System.out.println("TESTING...\n");
                   for(int index=0; index<firstName.size(); index++)
                        String first = firstName.get(index).toString();
                        String last = lastName.get(index).toString();
                        System.out.println("Hi, I am " + first + " " + last + ".");                    
              catch(Exception X) { System.out.println("EXCEPTION! "+X); X.printStackTrace(); }
    }

    Keeping the list in synch is conceptually easy.
    Basically anything you do to the one List, you have to do to the other in order to keep them consistent.
    How are you sorting your "firstnames" list?
    Using the Collections.sort method, or some manual coding?
    Would it be possible to change your datastructure from "parallel arrays" to "List of people objects"
    iepublic class Person {
      String firstName;
      String lastName;
      public Person(String firstName, String lastName){
        this.firstName = firstName;
        this.lastName = lastName;
      // appropriate getter/setter methods
    }Then you could build up your list like this:
    List friends = new ArrayList();
    friends.add(new Person("Ross", "Geller"));
    friends.add(new Person("Chandler", "Bing"));
      ...Now when you sort the list, the last name always goes with the first name because they are in the same object.
    You then write different Comparator objects to impose different orderings.
    Hope this helps,
    evnafets

  • Sorting a arraylist user defined object

    I'm curious as to how I would go about sorting an object that I created. I would like to sort the object by the name variable in the Employee class. I tried just doing Collections.sort(staff);, but that throws the 'ClassCastException' exception. Here is the code that I was working with.
    import java.util.*;
    import java.util.Collections.*;
    public class ArrayListTest {
         public static void main (String args[]) {
              ArrayList staff = new ArrayList();
              staff.add(new Employee("Harry Cracker", 50000, 1989, 10, 1));
              staff.add(new Employee("Tony Cracker", 40000, 1990, 3, 15));
              staff.add(new Employee("carl Cracker", 75000, 1987, 12, 15));
              for (int i=0; i<staff.size(); i++) {
                   Employee e = (Employee)staff.get(i);
                   e.raiseSalary(5);
              try {
                   Collections.sort(staff);
              catch (ClassCastException e) {
                   //e.printStackTrace();
                   System.out.println("got here1");
              catch (UnsupportedOperationException e) {
                   //e.printStackTrace();
                   System.out.println("got here1");
              for (int i=0; i<staff.size(); i++) {
                   Employee e = (Employee)staff.get(i);
                   System.out.println("name=" + e.getName() + "salary=" + e.getSalary() + ",hireDay=" + e.getHireDay());
    class Employee {
         public Employee(String n, double s, int year, int month, int day) {
              name = n;
              salary = s;
              GregorianCalendar calendar = new GregorianCalendar(year, month-1, day);
              hireDay = calendar.getTime();
         public String getName() {
              return name;
         public double getSalary() {
              return salary;
         public Date getHireDay() {
              return hireDay;
         public void raiseSalary(double byPercent) {
              double raise = salary * byPercent / 100;
              salary += raise;
         private String name;
         private double salary;
         private Date hireDay;
    }WHile I'm on this example if someone could explain what the Employee class is, shouldn't that be defined in a seperate file? It's not a inner class because it's not defined inside another class, but what would it be called and how come it works that way. If I go and put a private/public statement in front of it I get an error message. Thanks for the help.

    It doesn't know how to sort Employee, you have to implement Comparable or create a Comparator. You could change your Collections.sort() method to something like this: (remove the try and catch also)Collections.sort(staff, new Comparator()
        public int compare(Object o, Object o2)
            String s = ((Employee)o).getName();
            String s2 = ((Employee)o2).getName();
            return String.CASE_INSENSITIVE_ORDER.compare(s, s2);
    });That's at least one way.

  • I need help sorting an Array.

    Hi, I need to make a program that reads a string (sentence), then it counts the number of times each letter is "typed". As an optional challenge, the teacher told us to sort the results from the most repeated, to the least.
    My program is working pretty well, here is the code:
    import java.lang.String;
    //import java.util.Collections;
    //import java.util.*;
    public class count {
         final int alpha = 66;
         int [] lower = new int [alpha];
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              java.util.Scanner in = new java.util.Scanner (System.in);
              char current;
              final int alpha = 66;
              int [] lower = new int [alpha];
              int Spaces = 0;
    System.out.println("Enter a sentence:");
    String line = in.nextLine ();
    //int length = line.length();
    line = line.toLowerCase();
    for (int ch = 0; ch < line.length(); ch++)
    current = line.charAt(ch);
    if (current >= 'a' && current <= 'z')
    lower[current-'a']++;
    else if (current == ' ')
    Spaces ++;
    System.out.println();
    for (int letter=0; letter < lower.length;letter++)
         if (lower[letter]>0){
    System.out.print((char)(letter + 'a'));
    System.out.println(": " + lower[letter]);
         System.out.println ();
         System.out.println ("Spaces: " + Spaces);
         }[now, I want to sort the results. I tried using Arrays.sort(lower); but it doesnt work as it should. Example:
    String: Hello
    not sorted:
    e: 1
    h: 1
    l: 2
    o: 1
    Spaces: 0
    "sorted":
    : 1
    .:1
    ]:1
    ~:2
    Spaces: 0
    I would really appreciate your help.
    Thanks, J. Flemming

    Since you didn't post your Arraays.sort code, I can't
    tell what you did wrong.
    What does your array store? Element 0 is the number
    of 'a' occurences, 1 is 'b', etc?
    If so, then when you sort that, you'll have no idea
    which element corresponds to 'a'. You'll need a
    different approach for that. For instance, a class
    that encapsulates two pieces of data: character and
    number of occurences. You could then implement your
    own sort, or learn how to use Comparable/Comparator.
    Making Java
    Objects Comparable
    http://java.sun.com/docs/books/tutorial/collections/in
    terfaces/order.html
    http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-
    sort.htmlAs I said in my original post, I used Arrays.sort(lower), which is probably wrong. My Arrays does work as you described, element 0 is the numer of occurrences of 'a', and 1 is the number of occurrences of 'b' and so on. Thanks for your responce. Im looking into what you said. Thanks again.
    Message was edited by:
    Flemm.John

  • Need help with returning an array of object

    hello, i've been trying to make a method that returns bot ha boolean and a colour for a render for a Jtable and the code for the method is:
         public Object[] isHighlightCellsWithColour(int xInternal, int colInternal) {
              Object[] returnWithTwoValue;
              boolean isHighLight = false;
              returnWithTwoValue = new Object[2];
              returnWithTwoValue[0] = isHighLight;
              returnWithTwoValue[1] = null;
              if (colourPassed == true && this.foundDupeInternal > -1) {
                   for (int c6 = 0; c6 < foundDupeInternal; c6++) {
                        if (this.rows[c6] == xInternal && this.cols[c6] == colInternal) {
                             isHighLight = true;
                             Color colourToSet = errorColourList[c6];
                             returnWithTwoValue = new Object[2];
                             returnWithTwoValue[0] = isHighLight;
                             returnWithTwoValue[2] = colourToSet;
                             return returnWithTwoValue;
              } else {
                   return returnWithTwoValue;
              return null;
         }and when i go and try to use it at
              check = new Object[2];
              check = isHighlightCellsWithColour(xCurrentlyDrawing, colCurrentlyDrawing);
              boolean z = false;
              try {
                   z = (Boolean) check[0];
              } catch (NullPointerException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              Color x = Color.white;
              try {
                   x = (Color)check[1];
              } catch (NullPointerException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              it gives me a nullpointerexception, which i try to catch, but it STILL gives me that error, i have no clue on how to cast from object back to boolean or colour after they are cast into objects
    or else is there a way to pass two different types of data back from a method? Other than using static variables that is, since that gave me problems, it only draws the first cell in colum that is in error in the colour specified , not the rest...
    thanks for your time
    Edited by: TheHolyLancer on Mar 8, 2008 12:42 AM

    yay that got it working, but the method still only draws the first cell with the colour only, need another way to do this one...
    now comes another puzzeling question, it is giving me an null pointer exception again in:
    System.out.println("setting colour "+ x.getBlue() + " On cell " + xCurrentlyDrawing + colCurrentlyDrawing);when i add that to the part where i set the colour, and colour is set to x (which is a color that is passed down by the method) and this will only run if it is determined that a colour is already passed, but it still gives me null pointer error?
    maybe i'll take this to the swing forum tommrow
    Edited by: TheHolyLancer on Mar 8, 2008 2:17 AM
    Edited by: TheHolyLancer on Mar 8, 2008 2:19 AM

  • Need help in writing ABAP for and Object

    Hi ,
    I am an ABAPer and I need a help related to BW.
    As per the Client Requirement ,I need to write ABAP for object  ZC_MRPAMC.
    what he expects is :
    0MRP_CONTROL is an attribute of 0MAT_PLANT. There can be only one 0MRP_CONTROL per  0MAT_PLANT.
    Assign the attribute value of 0MRP_CONTROL to ZC_MRPAMC per 0MAT_PLANT.
    How to assign value of 0MRP_CONTROL to ZC_MRPAMC per 0MAT_PLANT.
    Kindly  give me the steps.
    Thanks.
    Anu.

    Hi,
    U can use FM RSAU_READ_MASTER_DATA.
    Give as input the info object(I_IOBJNM=0MAT_PLANT) and attribute name(I_ATTRNM=0MRP_CONTROL).
    Output u will get the value of that attribute which u want(E_ATTRVAL=ZC_MRPAMC).
    Hope it helps
    Regards,
    Rathy

Maybe you are looking for