All I'm tryin to do is set this up to show the array in the command prompt screen.
everything looks good to me,

C:\Users\Work Time\Desktop>javac SearchSource.java

but I keep getting this:

SearchSource.java:7: error: <identifier> expected
        System.out.print();
                        ^
1 error

Heres the program:

public class SearchSource
{
    public static void main (String[] args) {
    int[] SearchSource = newArray[6];
    SearchSource = new float[] {-3, 10, 5, 24, 45.3, 10.5};
    }
    System.out.print();
    {
        System.out.println("{" + SearchSource + "}\t");
    }
}

Any ideas?!? Help!

Recommended Answers

All 2 Replies

Everything in your code is wrong. Your declaration of int[] array in line 4 is wrong. it should be

int[] SearchSource = new int[6]

also you can't make an int[] array to contain data with float data types. It won't compile. If you want an array with float data types in it, why not declare it as float array?

float[] SearchSource = new float[6];

you can now use your code in line 5, although some correction are needed as it will not compile due to type mismatch error. 45.3 and 10.5 are not float, they're double. try 45.3f and 10.5f

SearchSource = new float[] {-3, 10, 5, 24, 45.3f, 10.5f};

You can't print nothing using System.out.print() in line 7. Maybe you should remove that together with the curly braces in line 6, 8, and 10. If you want to print the content of your array, try using for loop.

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.