GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes The Programme is not Compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "The Programme is not Compiling" Watch "The Programme is not Compiling" New topic
Author

The Programme is not Compiling

Zakir Hossain
Ranch Hand

Joined: Feb 14, 2006
Posts: 38
Below is the programme which is not compiling: please help.


import java.io.*;
import java.util.*;
public class GameHelper
{
private static final String alphabet = "abcdefg";
private int gridLength = 7;
private int gridSize = 49;
private int [] grid = new int[gridSize];
private int comCount = 0;

public String getUsetInput(String prompt)
{
String inputLine = null;
System.out.print(prompt + " ");
try
{
BufferedReader is = new BufferedReader ( new InputStreamReader (System.in));
inputLine = is.readLine();
if (inputLine.length() == 0) return null;
}
catch (IOException e)
{
System.out.println("IOException: " + e);
}
return inputLine.toLowerCase();
}
public ArrayList<String> placeDotCom(int comSize)
{
ArrayList<String> alphaCells = new ArrayList<String>();
String [] alphacoords = new String [comSize];
String temp = null;
int [] coords = new int[comSize];
int attempts = 0;
boolean success = false;
int location = 0;
comcount++;
int incr = 1;
if ((comCount % 2) == 1)
{
incr = gridLength;
}
while (!success & attempts++ < 200)
{
location = (int) (Math.random() * gridSize);
int x = 0;
success = true;
while (success && x < comSize)
{
if (grid[location] ==0)
{
coords[x++] = location;
location += incr;
if (location >= gridSize)
{
success = false;
}
if (x > 0 && (location % gridLength == 0))
{
success = false
}
}
else
{
success = false;
}
}
}
int x = 0;
int row = 0;
int column = 0;
while (x < comSize)
{
grid[coords [x]] = 1;
row = (int) (coords[x] / gridLengths);
column = coords[x] % gridLength;
temp = String.valueOf(alphabet.charAt(column));
alphaCells.add(temp(temp.concat(Integer.toString(row)));
x++;
}
return alphaCells;
}
}
------------------------


import java.util.*;
public class ArrayListMagnet
{
public static void man (String [] args)
{
ArrayList<String> a = new ArrayList<String> ();
a.add(0,"zero");
a.add(1,"one");
a.add(2,"two");
a.add(3,"three");
printAL(a);
if (a.contains("three"))
{
a.add("four");
}
a.remove(2);
printAL(a);
if(a.indexOf("four") != 4)
{
a.add(4, "4.2");
}
printAL(a);
if(a.contains("two"))
{
a.add("2.2");
}
printAL(a);
}

public static void printAL(ArrayList<String> a1)
{
for (String element : a1)
{
System.out.print(element + " ");
}
System.out.println(" ");
}
}
------------------

Error For ArrayListMagnet.java after compiling:

C:\jdk1.4\bin\ArrayListMagnet.java:6: '(' or '[' expected
ArrayList<String> a = new ArrayList<String> ();
^
C:\jdk1.4\bin\ArrayListMagnet.java:30: <identifier> expected
public static void printAL(ArrayList<String> a1)
^
C:\jdk1.4\bin\ArrayListMagnet.java:37: ')' expected
}
^
C:\jdk1.4\bin\ArrayListMagnet.java:6: cannot resolve symbol
symbol : variable ArrayList
location: class ArrayListMagnet
ArrayList<String> a = new ArrayList<String> ();
^
C:\jdk1.4\bin\ArrayListMagnet.java:6: cannot resolve symbol
symbol : variable String
location: class ArrayListMagnet
ArrayList<String> a = new ArrayList<String> ();
^
C:\jdk1.4\bin\ArrayListMagnet.java:6: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
ArrayList<String> a = new ArrayList<String> ();
^
C:\jdk1.4\bin\ArrayListMagnet.java:7: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.add(0,"zero");
^
C:\jdk1.4\bin\ArrayListMagnet.java:8: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.add(1,"one");
^
C:\jdk1.4\bin\ArrayListMagnet.java:9: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.add(2,"two");
^
C:\jdk1.4\bin\ArrayListMagnet.java:10: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.add(3,"three");
^
C:\jdk1.4\bin\ArrayListMagnet.java:11: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
printAL(a);
^
C:\jdk1.4\bin\ArrayListMagnet.java:12: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
if (a.contains("three"))
^
C:\jdk1.4\bin\ArrayListMagnet.java:14: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.add("four");
^
C:\jdk1.4\bin\ArrayListMagnet.java:16: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.remove(2);
^
C:\jdk1.4\bin\ArrayListMagnet.java:17: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
printAL(a);
^
C:\jdk1.4\bin\ArrayListMagnet.java:18: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
if(a.indexOf("four") != 4)
^
C:\jdk1.4\bin\ArrayListMagnet.java:20: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.add(4, "4.2");
^
C:\jdk1.4\bin\ArrayListMagnet.java:22: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
printAL(a);
^
C:\jdk1.4\bin\ArrayListMagnet.java:23: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
if(a.contains("two"))
^
C:\jdk1.4\bin\ArrayListMagnet.java:25: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
a.add("2.2");
^
C:\jdk1.4\bin\ArrayListMagnet.java:27: cannot resolve symbol
symbol : variable a
location: class ArrayListMagnet
printAL(a);
^
C:\jdk1.4\bin\ArrayListMagnet.java:30: missing method body, or declare abstract
public static void printAL(ArrayList<String> a1)
^
22 errors


cheers

Zakir


"The Choices We Make, Dictates Our Life To Lead".
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Generics (i.e., using <String> and such) is a Java 5 (JDK 1.5) feature. Based on your prompts above, it's clear you're using JDK 1.4. If you want to use these features -- and you should! -- then you need to upgrade to JDK 1.5. Given that JDK 1.6 is about to come out, I'd say it's time.


[Jess in Action][AskingGoodQuestions]
Zakir Hossain
Ranch Hand

Joined: Feb 14, 2006
Posts: 38
hi
well, from where I can get a JDK 1.5 version, Can you help me out

cheers
Zakir
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

http://java.sun.com, follow the "Java SE" link on the right-hand-side of the page.
 
GeeCON Prague 2014
 
subject: The Programme is not Compiling