• 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

The Programme is not Compiling

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Zakir Hossain
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://java.sun.com, follow the "Java SE" link on the right-hand-side of the page.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic