What I am trying to do is make a program that reads a txt file and converts the number into a double array.

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class rocket {

    public static void main(String[] args) throws IOException, FileNotFoundException
    {
       System.out.println(readLines("/Users/Jeremy/Documents/workspace/altitude.txt"));
    }
    public static Double[] readLines(String filename) throws IOException {
        FileReader fileReader = new FileReader(filename);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        List<Double> lines = new ArrayList<Double>();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            lines.add(Double.parseDouble(line));
        }
        bufferedReader.close();
        return lines.toArray(new Double[lines.size()]);
    }
}

This is my code, but when I run it I get [Ljava.lang.Double;@35960f05
A little info about my txt file, each number is on a seperateline and there is 26 numbers

[Ljava.lang.Double;@35960f05 is what you get when you call toString() on an array of Doubles (which is what println does when you print anything - it calls toString() to get a printable version). That toString method is inherited from Object.

There's a method in the Arrays class that converts arrays to the kind of string you want -
System.out.println(Arrays.toString(myArrayThatIWantToPrint));

commented: That worked Thanks! +2

is there any particular reason ur keeping your readlines method static?

edit : didnt see that james already posted there....

There isn't a reason for the static and that worked thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.