my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Problems with outputting arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problems with outputting arrays" Watch "Problems with outputting arrays" New topic
Author

Problems with outputting arrays

Matt Hall
Greenhorn

Joined: Feb 28, 2006
Posts: 24
When trying to output an array with

System.out.println(DHand1[]);

i get an error message '.class' expected

import java.io.*;

public class Cards {

static int DHand1[] = new int[13]; //Creates the array

/** Creates a new instance of Cards */
public static void main() {
DHand1[2] = 15; //Assigns position 2 of the array with a value of 15
System.out.println(DHand1[]);
}
}

Any help would be appriciated, thx.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
You need to specify a position in the array for it to print.

Also if you want to program to run correctly, you need to make sure the main method has the right signature.

Here is one way to print the contents of the array.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with outputting arrays
 
Similar Threads
Random number generation
illegal start of expression
shuffling
Array item selection
Array item selection