CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2014
    Posts
    1

    Test class returning null

    Hi, I'm a beginner programmer so apologies if this seems like a stupid question!

    I've tried to initialize my field numbers with an array of numbers in a constructor in one class and then call it in my test class and display it as a string but it keeps returning null....any help would be appreciated!

    This is my class that has the constructor

    Code:
    public class NumerbList implements Number {
        ArrayList<Number> numbers = new ArrayList<Number>();
    
        //constructor taking array of type double as parameter
        public NumberList(Double[] numberlist){
            for(int i=0; i<numberlist.length; i++){
                NumberDouble numberd = new NumberDouble(numberlist[i]);
                numbers.add(numberd);
            }
        }
    and this is the class that tests it
    Code:
     
    public class Test {
        public static void main(String[]args){
            Double[] d = {2.4, 3.6, 4.3, 5.1};
            NumberList numbers = new NumberList(d);
            numbers.neg();
    
            System.out.print(numbers.asString());
        }
    }

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: Test class returning null

    Does the code you posted compile OK? If there are errors, copy the full text and paste it there.
    Norm

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured