ArrayTest


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: ArrayTest

  1. #1
    Join Date
    Aug 2005
    Posts
    14

    ArrayTest

    its saying, the compiler that ")" is expected in the system.out.println line, line 18 but i think i did this and the error was still there. im guesssing ive made a mistake in my program elsewhere.




    public class ArrayTest
    {
    int[] table = new int[4]; //integer array with 4 slots

    public static void main(String[] args)
    {
    table[0] = 10; // the first index in an array is 0
    table[1] = 20;
    table[2] = 30;
    table[3] = 40;

    printTable(); //method call to the printTable method/function
    }
    void printTable();
    {
    for(int i=0; i<table.length; i++) //loop
    {
    System.out.println(printing: + table[i]); // print statement
    }
    }
    }

  2. #2
    Join Date
    Aug 2005
    Posts
    43
    Since println takes a String as argument, you have to specify it when you want to print out "printing: "....
    So, it should be:
    Code:
    System.out.println("printing: " + table[i]);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center