• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems with outputting arrays

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic