0

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!

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by JWarren1996
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.