DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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]);

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links