Passing arrays to methods?

Hi all,
Thanks to most of the main contributors in this forum nearly all of my major hurdles in transitioning from proc-C to Cocoa have been overcome. However, while I was shown how to use NSMutableArray in conjunction with NSDictionary to do pretty much the same job as a C-style multi-dimensional array, dictionaries aren't always the perfect solution in every situation. So, let's suppose I wanted to construct a pure Cocoa facsimile of a C-style [4][x] array like this...
NSArray *replicaArray = [NSArray arrayWithObjects:
[NSNull null], // index 0 (unused)
[NSMutableArray array], // index 1
[NSMutableArray array], // index 2
[NSMutableArray array],nil]; // index 3
I threw in an NSNull as the first array object because (whenever possible) I adopted the habit of leaving row0 and column0 of multidimensional arrays unused to make for more natural, readable iteration ops and stuff. The above code works perfectly well, but with 4-5 different arrays in the same proc-C apps I often had to pass them to common functions (to handle things like bubble-sorting etc.) like the one below:
void bubbleSortSimpleArray (short arry[ ], short numsToSort)
short ctr,loopCtr,storeValue;
for (loopCtr = 1; loopCtr <= numsToSort; loopCtr++)
ctr = 1;
while (ctr < numsToSort)
if (arry[ctr] > arry[ctr+1])
storeValue = arry[ctr+1];
arry[ctr+1] = arry[ctr];
arry[ctr] = storeValue;
++ctr;
Of course, thanks to the advantages of Cocoa this entire code block can be replaced in just a couple lines with 'sortUsingSelector'. Sorry for the lengthy outline in attempting to describe my problem as clearly as possible , but (finally) _is it possible to pass arrays to methods_ in our Cocoa code in a similar way? I was thinking something along the lines of:
- (void)doMoreProcessing:(id)array
//do some other common stuff on my array(s) here...
That'd simplify converting some of my old code and be a real bonus for me, but I haven't been able to find any reference about this on the net so far, and experimenting with my code hasn't provided me with any answers yet, either... Any guidance on this would be very much appreciated!
Thanks in advance.
Ernie

Hi Bang A. Lore,
Thanks for your input but I've got it figured out now However, while you quite correctly say:
Pointers work the same way as they do in C.
the cause of my problems wasn't a lack of understanding of pointers, but by the syntax differences between proc-C and obj-C. I'm well aware of the fact that the name of a passed array is just a pointer to its address in memory of course, but attempting to use a mandatory 'C' style header declaration along the lines of:
- (void)test2DArray:(NSMutableArray*)array[][];
just kept giving me parse errors, as did any attempt to use square brackets in the implementation file. While 'C' insists on using them, I found (after some more experimentation) that obj-C will quite happily accept:
- (void)test2DArray:(NSMutableArray*)array;
...or the even simpler...
- (void)test2DArray:(id)array;
Also pleasantly surprised to find that Cocoa doesn't seem to give a hoot whether the (array) object you pass it is flat OR multidimensional -- whereas 'C' insists you even provide the called function with the number of rows contained in a multi-subscripted array -- which often meant I had to include two versions of many functions containing identical code, depending on whether they were called by 1D or 2D arrays.
Once I hit on the idea of omitting the square brackets entirely (just to stop the darned parse errors and see what would happen out of curiosity), the problem just went away.
Thanks once again. Appreciate it!

Similar Messages

  • Passing array as method to activex

    Dear Users;
    Sorry if this is a repeat question - I could not find relevant code in the faq.
    I have an activeX control which contains a method (PassArray) which accepts an array, and modifies its contents... The array *seems* to be correctly passed in, and I can make the modifications to the data. The data is then passed back out... In labview I use the Variant -> Data object to return the underlying dataset. However all my modifications are lost. (Sample code below).
    Ie: it seems Labview is passing me a copy of the original data, and does not accept that changes have occured. When I create a method which returns a variant containing a new array (ReturnArray), everything works properly. Does this occur because methods use 'const' keywords for parameters? Is there a solution where labview accepts that the data has changed?
    Any hints would be useful...
    thanks,
    Marc
    VARIANT CAcxLVArrayCtrl::ReturnArray(short Lendth)
    VARIANT vaResult;
    VariantInit(&vaResult);
    // TODO: Add your dispatch handler code here
    // Ok use this code to generate an array based upon size of Lendth.
    double* lpusBuffer;
    //Assigns the Variant to hold an array of doubles (real 8-byte numbers)
    vaResult.vt = VT_ARRAY | VT_R8;
    SAFEARRAYBOUND rgsabound[1];
    //Set bounds of array
    rgsabound[0].lLbound = 0; //Lower bound
    rgsabound[0].cElements = Lendth; //Number of elements
    //Create the safe array of doubles, with the specified bounds, and only 1 dimension
    vaResult.parray = SafeArrayCreate( VT_R8, 1, rgsabound );
    SafeArrayAllocData( vaResult.parray );
    SafeArrayAccessData( vaResult.parray, (void**)&lpusBuffer );
    //Fill in the buffer
    for( int i=0; i
    *(lpusBuffer + i ) = i + 1;
    SafeArrayUnaccessData( vaResult.parray );
    return vaResult;
    short CAcxLVArrayCtrl:assArray(const VARIANT FAR& ArrayInOut)
    // TODO: Add your dispatch handler code here
    long LowerBound, UpperBound, cbElements;
    if(ArrayInOut.vt != (VT_ARRAY | VT_I4))
    MessageBox("Data is not an array of Longs");
    return -1;
    if(SafeArrayGetDim(ArrayInOut.parray) != 1)
    MessageBox("Data must be a 1D array");
    return -1;
    SafeArrayGetLBound(ArrayInOut.parray, 1, &LowerBound);
    SafeArrayGetUBound(ArrayInOut.parray, 1, &UpperBound);
    if( (UpperBound - LowerBound) = 0)
    MessageBox("Data array is not initialised");
    return -1;
    long* lpusBuffer;
    SafeArrayAccessData( ArrayInOut.parray, (void**)&lpusBuffer );
    //Fill in the buffer
    for( int i=LowerBound; i
    *(lpusBuffer + i ) = i + 1;
    SafeArrayUnaccessData( ArrayInOut.parray );
    return 0;

    Fortunately I was able to determine what I was doing wrong. LabView and Visual Basic for Applications (VBA) only support the VARIANT data type for arrays. Visual Basic, however, supports more descriptive array parameter specifications in IDL. In other words, there are numerous valid ways to declare array parameters in IDL, however, some tools only support a subset. LV only supports VARIANTs. So in the previous IDL example:
    [id(3), helpstring("method NSEnumDevice")] HRESULT NSEnumDevice([in] int devIndex, [in] SAFEARRAY(int) *ports);
    becomes -
    [id(3), helpstring("method NSEnumDevice")] HRESULT NSEnumDevice([in] int devIndex, [in] VARIANT ports, [out, retval] VARIANT *devObj);
    Where devObj is an ActiveX wrapped object. VARIANT "ports" is an array of integer values. To specify returning an array of values, you still just use "[out, retval] VARIANT *array".
    --ddixon

  • Passing array via methods

    I am trying to enter x amount of marks by passing a method but placing in an array. When i compile i get no faults but method isn't passing. if i set a number it works but only to to that set number.
    Any help would be appreciated.
    import javax.swing.*;
    public class HomeWork8Week10
         public static void main(String args [])
              int mark = 0;
              getInt(mark);
              int size=0;
              getMarks(size);
         private static int getInt(int mark)
              String number = JOptionPane.showInputDialog(null,"Enter number of marks",
                                  "Homework 8",JOptionPane.QUESTION_MESSAGE);
              return Integer.parseInt(number);
         public static int[] getMarks(int size)
              int[] marks = new int[size];
              for(int i =0; i<marks.length; i++)
                   String numberOfMarks = JOptionPane.showInputDialog(null,"Enter mark",
                                  "Homework 8",JOptionPane.QUESTION_MESSAGE);
                   marks[i] = Integer.parseInt(numberOfMarks);
              return marks;
    }

    Right, and anticipating a possible questions, you'd code it like this:
    int[] results = getMarks(marks);
    Also, there seems not need to send the method getInt anything at all.

  • Errors compiling program - passing array to method

    My program has several errors when compiling and I don't know what I am missing? I would appreciate any tips about where to look if it's syntax, missing curly braces, anything. I am doing this as a practice for my midterm tonight and we can use our notes but they won't help me much if I have them wrong.. Thanks in advance for any help. I will list the errors then a copy of what Ive written.
    '.class' expected
    int[]date = int new[3];
    illegal start of expression
    public static int verifyDate(int [] d)
    ';' expected
    unexpected type
    required: value
    found : class
    int[]date = int new[3];
    cannot resolve symbol
    symbol: method verifyDate (int[])
    location: class MidTermPractice.MidTerm
    int check = verifyDate(date);
    imcompatible types
    found : int
    required: boolean
    if (check = 0)
    /* Rhonda Roberson
    * MidTerm.java
    * Practice Midterm
    * Created on November 17, 2004, 4:08 PM
    package MidTernPractice;
    import javax.swing.JOptionPane;
    public class MidTerm
    //Main method
    public static void main(String[]args)
    int[]date = int new[3];
    String monthAsString = JOptionPane.showInputDialog(null,
    "Enter Month", "Enter Month as a number", JOptionPane.PLAIN_MESSAGE);
    date[0] = Integer.parseInt(monthAsString);
    String dayAsString = JOptionPane.showInputDialog(null,
    "Enter Day", "Enter Day as a number", JOptionPane.PLAIN_MESSAGE);
    date[1] = Integer.parseInt(dayAsString);
    String yearAsString = JOptionPane.showInputDialog(null,
    "Enter Year", "Enter 4 digit Year", JOptionPane.PLAIN_MESSAGE);
    date[2] = Integer.parseInt(yearAsString);
    //Call VerifyDate() Method
    int check = verifyDate(date);
    //Print Message if date is valid
    if (check = 0)
    JOptionPane.showMessageDialog(null, "Date is Valid");
    else
    JOptionPane.showMessageDialog(null, "Date is NOT VALID");
    //************Method to verify date
    public static int verifyDate(int [] d)
    int check = 0;
    if (d[0] < 1 || d[0] > 12)
    check = 1;
    if(d[1] < 1 || d[1] > 31)
    check - 1;
    if(d[2] < 1900 || d[2] >2100)
    check = 1;
    return check;

    '.class' expected
    int[]date = int new[3];
    You need a space between int[] and date and it should be "= new int[3];"
    unexpected type
    required: value
    found : class
    int[]date = int new[3];
    Same as above
    imcompatible types
    found : int
    required: boolean
    if (check = 0)
    The Java operator to compare two values is == not =

  • How can i pass array as argument in magento api method calling using sudzc API in iphone Native APP

    0down votefavorite
    I am implementing magento standard api method in native iphone app. I use webservice generated by sudzc. To call method I use:
    [service call:self action:@selector(callHandler:) sessionId:@" " resourcePath:@" " args:@""];
    When I used methods e.g. cart.info or product.info in which I have to pass one parameter; it gives valid response. But when I used method e.g. cart_product.add in which I have to pass an argument as value of array it gives error
    SQLSTATE[42000]: Syntax error or access violation:
        1064 You have an error in your SQL syntax;
        check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
    I have tested in SOAP UI also. There also it gives me same error. But same method works in PHP file. Even I tried by creating same soap request which I created using JavaScript but still it doesn't work.
    Can anyone help me to pass array as a parameter using sudzc api to call magento web services?

    There is an error in your SQL.

  • Passing array from JS to method of applet

    There is unable in IE pass array of values from javascript to method of applet, but in Mozilla it's working fine. In IE i have got exception:
    Exception:
    java.lang.Exception: setTest{0} :no such method exists
         at sun.plugin.com.JavaClass.getMethod1(Unknown Source)
         at sun.plugin.com.JavaClass.getDispatcher(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    java.lang.Exception: java.lang.Exception: setTest{0} :no such method exists
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    JavaScript code:
    var testArr=[];
        testArr[0]=1;
        testArr[1]=2;
        testArr[2]=3;
        document.sync.setTest(testArr);
    Applet method:
    public void setTest(Object[] test){
            System.out.println("Test "+test.length);
            for (Object o: test){
                System.out.println(o.toString());
        }How do passing in IE?

    yes, MAYSCRIPT just allow to call methods. but as i know it's unable to pass simply array from js to applet and from applet to js. so i convert array of values to String and in applet i use StringTokenizer to parsing. Thanks. ;)

  • Passing array to a method through actionevent? ??

    what the hell is this guy on about your asking..
    well.. i have a user defined data structures (people)
    and i'm creating my first gui, so i have an action caught with
    public static void main(String[] args)
    int MAX = 1000;
    person[] ppl;
    ppl = new person[MAX];
    public void actionPerformed(ActionEvent e) {
    if(e.getSource() == addNewPerson) {
    //method call in here to add new person
    //but how can i pass the array this far so i can then give it
    //to my method, or am i looking at this all wrong?
    }if as the comments suggests, i'm calling this all wrong, what way should i implement this? i'm basically getting cannot resolve symbol, pointing to my method which adds a new person (so as i said before, it needs to be passed to the method)

    You might want start by reading a few books on OO design first.
    What you will probably want to do is have a class which stores the array and extends ActionListener...
    public class Gui extends ActionListener {
      Person[] ppl = new Person[100];
      Component comp;
      Button addPersonButton;
      public Gui () {
        comp = new .....;
        addPersonButton = new Button("Add person");
        comp.add(addPersonButton);
        comp.addActionListener(this);
      public static void main(String args[]) {
        Gui gui = new Gui();
      public void actionPerformed(ActionEvent e) {
        if (e.getSource() == addPersonButton) {
          doAddPerson();
      pulbic void doAddPerson() {
        ppl[0] = ....
    }Hope this shows you a bit more. Not sure how good my design of gui's is though :-/
    Rob.

  • Passing Array to a method

    Hi,
    There is a class MyClass that implements Serializable. I need to create array of this class and pass to a method.
    In java, this can be done as following:
                   MyClass[] myClassVariables=new MyClass[2];
                   MyClass myClassInstance1=new MyClass();
                   MyClass myClassInstance2=new MyClass();
                   myClassVariables[0]=myClassInstance1;
                   myClassVariables[1]=myClassInstance2;
                   String message = getValues(myClassVariables);
    import java.io.Serializable;
    public class MyClass implements Serializable{
    public String getValues(MyClass[] myClassVariables)
    When I implement this in a workflow, I get the following error:
    XPRESS exception:
    com.waveset.util.WavesetException: Couldn't find method getValues(java.lang.String, java.lang.String) in class MyClass
    java.lang.NoSuchMethodException: MyClass.getValues(java.lang.String, java.util.ArrayList)
    Code I am using is as following:
    <set name='myClassInstance1'>
    <new class='com.marathon.MyClass'/>
    </set>
    <set name='myClassInstance2'>
    <new class='com.marathon.MyClass'/>
    </set>
    <set name='myList'>
    <new class='java.util.ArrayList'/>
    </set>
    <set name='myClassVariables'>
    <list>
    <ref>myClassInstance1</ref>
    <ref>myClassInstance2</ref>
    </list>
    </set>
    <set name='message'>
    <invoke name='getValues' class='MyClass'>
    <ref>myClassVariables</ref>
    </invoke>
    </set>
    <ref>message</ref>
    Please help me,
    Thanks

    You might want start by reading a few books on OO design first.
    What you will probably want to do is have a class which stores the array and extends ActionListener...
    public class Gui extends ActionListener {
      Person[] ppl = new Person[100];
      Component comp;
      Button addPersonButton;
      public Gui () {
        comp = new .....;
        addPersonButton = new Button("Add person");
        comp.add(addPersonButton);
        comp.addActionListener(this);
      public static void main(String args[]) {
        Gui gui = new Gui();
      public void actionPerformed(ActionEvent e) {
        if (e.getSource() == addPersonButton) {
          doAddPerson();
      pulbic void doAddPerson() {
        ppl[0] = ....
    }Hope this shows you a bit more. Not sure how good my design of gui's is though :-/
    Rob.

  • Getting Type Mismatch Error while passing Array of Interfaces from C#(VSTO) to VBA through IDispatch interface

    Hi,
    I am facing issues like Type Mismatch while passing Array of interfaces from .NET  to VBA and vice versa using VSTO technology.
    My requirement is that ComInterfaceType needs to be InterfaceIsIDispatch.
    My Interface definition is somewhat like this
        [ComVisible(true)]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        [Guid("AAF48FBC-52B6-4179-A8D2-944D7FBF264E")]
        public interface IInterface1
            [DispId(0)]
            IInterface2[] GetObj();
            [DispId(1)]
            void SetObj(ref IInterface2[] obj);
        [ComVisible(true)]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        [Guid("CDC06E1D-FE8C-477E-97F1-604B73EF868F")]
        public interface IInterface2
    IF i am passing array of above interface (created in C#.Net) to VBA using GetObj API,i am getting type mismatch error in VBA while assigning the value to variable in VBA.Even assigning to variant type variable gives TypeMismatch.
    Also while passing Array of interfaces from VBA using SetObj API,excel crashes and sometimes it says method doesn't exists.
    Kindly provide some assistance regarding the same.
    Thanks

    Hi,
    I am facing issues like Type Mismatch while passing Array of interfaces from .NET  to VBA and vice versa using VSTO technology.
    My requirement is that ComInterfaceType needs to be InterfaceIsIDispatch.
    My Interface definition is somewhat like this
        [ComVisible(true)]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        [Guid("AAF48FBC-52B6-4179-A8D2-944D7FBF264E")]
        public interface IInterface1
            [DispId(0)]
            IInterface2[] GetObj();
            [DispId(1)]
            void SetObj(ref IInterface2[] obj);
        [ComVisible(true)]
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        [Guid("CDC06E1D-FE8C-477E-97F1-604B73EF868F")]
        public interface IInterface2
    IF i am passing array of above interface (created in C#.Net) to VBA using GetObj API,i am getting type mismatch error in VBA while assigning the value to variable in VBA.Even assigning to variant type variable gives TypeMismatch.
    Also while passing Array of interfaces from VBA using SetObj API,excel crashes and sometimes it says method doesn't exists.
    Kindly provide some assistance regarding the same.
    Thanks

  • Unable to detect any parameter in html (webresource) when value is passed from onload method of form

    Unable to detect any parameter in html (webresource) when value is passed from onload method of form
    I am trying out some stuff. For which I created a simple Entity. In the form of the entity I have added a simple web resource (html). And for the onload of the form I am calling the following function
    function HelpDeskActivityOnLoadhandler()
     var customParameters = encodeURIComponent("first=First Value&second=Second Value&third=Third Value");
        Xrm.Utility.openWebResource("tsi_scriptzz",customParameters);
    Here is the code for the  tsi_scriptzz.html
    <html>
     <body>
      <script type="text/javascript">
        var vals = new Array();
        if (location.search != "") {
         vals = location.search.substr(1).split("&");
         for (var i in vals) {
          vals[i] = vals[i].replace(/\+/g, " ").split("=");
      </script>
     </body>
    </html>
    MY PROBLEM IS -> location.search is always coming back with empty string. So, it not getting the parametrs I am passing from the load method of the form.
    Could someone kindly help me.
    Thanks,
    Hasib

    Hello, I tried it myself. I got a new_test.htm file and a new_test.js file. The loadWebResource function is called on the OnLoad event of an Entity.
    function loadWebResource()
    var params = encodeURIComponent('param1=value one&param2=value two&param3=value three');
    Xrm.Utility.openWebResource('new_test.htm', params);
    <html>
    <head>
    <title>Web Resource Parameter Example</title>
    <!-- Use ../ClientGlobalContext.js.aspx if your webresource is in a deeper folder on CRM -->
    <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
    <script type="text/javascript">
    document.onreadystatechange = function () {
    if (document.readyState == 'complete') {
    var params = getParams();
    for(var i=0; i<params.length; i++)
    log(params[i].name + ' ' + params[i].value);
    // this functions puts the params in a 'dictionary format'
    // f.e params[0].name = param1 & params[0].value = 'value one'
    // You could customize this function or find some on the internet to retrieve a param fe by name...
    // This is just an example how to get the name and values
    function getParams(){
    var params = [];
    var querystring = Xrm.Page.context.getQueryStringParameters().Data;
    var querystringparts = querystring.split('&');
    for(var i=0; i<querystringparts.length;i++)
    var split = querystringparts[i].split('=');
    params.push({
    name: split[0],
    value: split[1]
    </script>
    </head>
    <body>
    </body>
    </html>
    Hope it helps now. Kind Regards

  • Passing Arrays to a mathod

    I was wondering how I would be able to pass 2 arrays to 1 method?
    I have array a and array b, which I need to pass to a method that will add them together and return the result in array c. but I just need to know how to pass the two arrays into the method for now.

    return the result in array c
    int[] someMethod(int[] arr1, int[] arr2) {                                                                                                                                                                                   

  • Passing array to remote object.

    Hi All,
       I'm able to pass 'String' to RemoteObject method but can someone please let me know how to pass array to remoteobject.
      Say I have following array:
       public var mySourceDataProvider:Array = new Array({isRowSelected: false, name:'Name1', age:10, comment:'Comment1'},
                             {isRowSelected: false, name:'Name2', age:20, comment:'Comment2'},
                             {isRowSelected: false, name:'Name3', age:30, comment:'Comment3'},
                             {isRowSelected: false, name:'Name4', age:40, comment:'Comment4'});
      I'd like to pass this array to RemoteObject method.
      Thanks in advance.
    Regards,
    Sharath.

    Say I have 'mySourceDataProvider' array, which I'd like to pass to RemoteObject method in backend....how to declare this RemoteObject method which takes array from flex UI.
    If this not clear then let me know, I'll try to send some sample code...

  • Sharing an array between methods

    I have three classes as follows
    import javax.swing.*;
    public class result
    String names, date, scores, records;
    public result(String na, String da, String sc)
         names=na;
         date=da;
         scores=sc;
    public String getName()
            return names;
    public String getDate()
            return date;
    public String getScore()
            return scores;
    import javax.swing.*;
    public class resultList 
    final int DEFAULT_SIZE = 20;
    int count;
    result[] data;
    public resultList()
    data = new result[DEFAULT_SIZE];
    count = 0;
    public resultList(int size)
    data = new result[size];
    count = 0;
    public void insert( result  myResults )
    data[count] = myResults;
    count++;
    public result[] getResult()
    return data;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    public class Sport
    public static void main (String[] args)
    boolean alive = true;
    try     
    while (alive)
    String menu = JOptionPane.showInputDialog(   //This the menu the user see's
    "Select 1 to input results\n"+
    "Select 2 to linearsearch\n"+
    "Select 3 to Check contents of  array\n"+
    "Select 0 to Quit");
    int menu2=Integer.parseInt(menu);
    if (menu2==1)           //i use if statements to match the methods with the menu
    inputteams();
    if (menu2==2)
    linearsearch();
    if (menu2==3)
    printArray();
    if (menu2==0)
    alive = false;
    catch (IOException e)
    System.err.println("Caught IOException: "+ e.getMessage());
    public static void inputteams()throws IOException
    resultList myList = new resultList();
    int count = 0;
    int stillContinue = JOptionPane.YES_OPTION;
    while (stillContinue == JOptionPane.YES_OPTION)
    String na = JOptionPane.showInputDialog("Please, enter team name");
    String da = JOptionPane.showInputDialog("Enter date:");
    String sc = JOptionPane.showInputDialog("Please enter score");
    if (na!=null && da!=null && sc!=null)
    result data = new result(na, da, sc);
    myList.insert(data);
    else
    JOptionPane.showMessageDialog(null,"Please enter all required data");
    stillContinue = JOptionPane.showConfirmDialog(null, "Enter another record?",
    "???", JOptionPane.YES_NO_OPTION);
    count++;
    public static void printArray() 
    resultList myList = new resultList();
    result[] data = myList.getResult(); 
    for( int i=0; i<data.length; i++)
    result myResults = data;
    if( myResults != null )
    System.out.println("Database contents" + myResults.toString());
    else
    System.out.println("232"); //Handling empty elements in the array
    }               //to avoid return of nullPointer
    }When i run the program and the menu pops up, i enter one and start inputting data.  Once i have completed this the menu pops up again.  This time i choose 3 to print the contents of my array.  However, all this does is print 232 numerous times which shows that the array i am creating in my printArray() is not being passed the contents of my array.  I have used a similar procedure to what i am doing in a different rpogram and it seems to work.  I cant see why this time the contents of my filled up array isnt being passed to this method.  Any advice on where i am going wrong?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    public static void main (String[] args)
    boolean alive = true;
    resultList rl = new resultList();
    Sport sport = new Sport();
    try     
    while (alive)
    String menu = JOptionPane.showInputDialog(   //This the menu the user see's
    "Select 1 to input results\n"+
    "Select 2 to linearsearch\n"+
    "Select 3 to Check contents of  array\n"+
    "Select 0 to Quit");
    int menu2=Integer.parseInt(menu);
    if (menu2==1)           //i use if statements to match the methods with the menu
    sport.inputteams(rl);
    if (menu2==2)
    sport.linearsearch(rl);
    if (menu2==3)
    sport.printArray(rl);
    if (menu2==0)
    alive = false;
    catch (IOException e)
    System.err.println("Caught IOException: "+ e.getMessage());
    public  void inputteams(resultList l)throws IOException
    //resultList myList = new resultList();
    int count = 0;
    int stillContinue = JOptionPane.YES_OPTION;
    while (stillContinue == JOptionPane.YES_OPTION)
    String na = JOptionPane.showInputDialog("Please, enter team name");
    String da = JOptionPane.showInputDialog("Enter date:");
    String sc = JOptionPane.showInputDialog("Please enter score");
    if (na!=null && da!=null && sc!=null)
    result data = new result(na, da, sc);
    l.insert(data);
    else
    JOptionPane.showMessageDialog(null,"Please enter all required data");
    stillContinue = JOptionPane.showConfirmDialog(null, "Enter another record?",
    "???", JOptionPane.YES_NO_OPTION);
    count++;
    public void printArray(resultList l) 
    //resultList myList = new resultList();
    result[] data = l.getResult(); 
    for( int i=0; i<data.length; i++)
    result myResults = data;
    if( myResults != null )
    System.out.println("Database contents" + myResults.toString());
    else
    System.out.println("232"); //Handling empty elements in the array
    }               //to avoid return of nullPointer
    private void linearsearch(resultList l) {
    // throw new UnsupportedOperationException("Not yet implemented");
    }Edited by: d3n0 on Apr 14, 2008 8:10 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Passing arrays to Oracle Stored procedure.

    Have any body passed arrays to Oracle stored procedures while the app is running in Weblogic app server. I am able to pass the arrays with regular JDBC connection. If I run the same piece of code using a connection recieved from the datasource of weblogic server, its not working. I am getting serialization errors with the ArrayDescriptor class. Looks like the ArrayDescriptor is not serializable.
    Does anybody know solution/workaround to pass arrays ?
    Thanks in advance

    you could write a wrapper class that extends ArrayDescriptor and implements serializable...
    for example your class would look something like this.
    public class MyArrayDescriptor extends ArrayDescriptor
    implements Serializable
    in your regular code use the wrapper class in place of the ArrayDescriptor (it will contain all the same methods as the real ArrayDescriptor) and you should be able to toss your wrapper class anywhere you please.

  • Passing array of long as Web Service parameter

    Hello,
    Is it possible in apex pass array as paramater ? I have method with one paramater Long[]: Numbers. Any idea, plsease.
    Thank you.

    This might be helpful. You can create an application process (Shared Component) and call it while passing arrays.
    Passing an array with htmldb_get
    It isn't specifically about longs but, you should be able to move from their string to their numeric representations.
    -Joe

Maybe you are looking for

  • Originals tab details

    I would like the details to be populated on the Originals tab and have verified that the 'content version' is checed off for all my document types, and it is...is there something else that needs to be done/configured in order for the Status Txt / Use

  • How to configure traveling MacBook and airport express

    Here is the probelm I am interested in getting help with I frequently travel with my family with Mac Books and an airport express. When we are at a hotel we dont want to pay for 5 internet connections at the daily rate. So if the hotel has an etherne

  • Generate Preview - Save for Web Crashes Photoshop

    Ok so when using Photoshop CS3 for web use i usually save for the web and preview in firefox, Now i had a few issues with photoshop, and so reinstalled my system, However since this now when i go to save for web, then preview image, Photoshop freezes

  • Can't see particles in Particle Playground

    I'm unable to see particles being created by the Particle Playground effect. I can apply the CC particle effects with no problem, but when I try it with Particle Playground I just get a black screen. The info window counts the particles and the timel

  • Adobe Download Assistant does'nt start the download of Photoshop CS6 trial automatically. What shoul

    Adobe Download Assistant does'nt start the download of Photoshop CS6 trial automatically. What should I do?