How am i getting an illegal start of expression error?

Hi,
i am new to this forumn, and still fairly new to java i gues. i get an illegal start of expression in the following code at the line...
data [arrayCounter] = {fn,ln,hp,ha,hc,hs,hz};
any ideas as to why?
    public class customersDatabase {
        String[] columnNames = new String[10];
        private Object[][] theData = new Object[1000][10];
        public customersDatabase() {
        String[] employeeNameArray = new String[10];
        String retrieveString = "SELECT * FROM customerTable";
        Statement stmt;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch(java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        try {
            con = DriverManager.getConnection(url, null, null);
            stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(retrieveString);
            int arrayCounter = 0;
            while (rs.next()) {
                String fn = rs.getString("FIRSTNAME");
                String ln = rs.getString("LASTNAME");
                String hp = rs.getString("HOMEPHONE");
                String ha = rs.getString("HOMEADDRESS");
                String hc = rs.getString("HOMECITY");
                String hs = rs.getString("HOMESTATE");
                String hz = rs.getString("HOMEZIP");
                data [arrayCounter] = {fn,ln,hp,ha,hc,hs,hz};
                System.out.println(fn+ln+hp+ha+hc+hs+hz);
                arrayCounter ++;
            stmt.close();
            con.close();
        } catch(SQLException ex) {
            System.err.println("SQLException: " + ex.getMessage());
    }

Change it to:
data [arrayCounter] = new String[] {fn,ln,hp,ha,hc,hs,hz};(or new Object[], but I don't know why your array is declared as Object[][], anyway, if you only put Strings in it.
You can only use the initialization you used when first declaring the variable.
Also, "data" should be "theData", I think.

Similar Messages

  • Illegal start of expression error

    Hi, I keep getting an illegal start of expression error at the first parentheses of the main method, and I can't find the reason why. Any hints?
    import java.util.*;
    import java.io.*;
    import java.text.*;
    public class driver
        public static void main(String[] args)
              private String numerator, denominator;
              private Scanner inScan = new Scanner(System.in);
              System.out.print("Enter a numerator: ");
              numerator = inScan.nextLine(); //get numerator
              System.out.print("Enter a denominator: ");
              denominator = inScan.nextLine(); //get denominator
              EgyptianFraction fraction = new EgyptianFraction(numerator,denominator);
    }

    String numerator, numerator;
    Scanner inScan = new Scanner(System.in);Variables numerator, numerator and inScan are local variable, so there is no private modifer.
    Suggestion: name your class Driver. There is a widely held coding convention that classes should start with a capital letter.

  • Why "illegal start of expression" error?  Please help!

    Hello great java minds. Could you please tell me why I get "illegal start of expression" errors for the following headers? Thanks for your wisdom!!
    Lines generating this error:
    public static String getName()--and--
    public static void displayResults()Here is my first class (that includes this code):
    import java.io.*;
    import java.util.*;
    public class ProductSurvey
         public static void main(String [] args)
              ProductData myData = new ProdcutData();
              String name = getName();
              openFile();
              myData.setName(name);
              myData.dataRetrieve(name);
              myData.updateAverages(rating1totalLow, rating2totalLow, rating3totalLow, rating1totalMed, rating2totalMed, rating3totalMed, rating1totalHigh, rating2totalHigh, rating3totalHigh, inc1total, inc2total, inc3total);
              mydata.setRating2ave1lower3(rating2lower1than3, lower1than3Total);
              displayResults();
              public static String getName()
                   System.out.println("Please enter income and product info file name:  ");
                   Scanner keyboard = new Scanner(System.in);
                   String name = keyboard.next();
                   return name;
              public static void openFile();
                   File fileObject = new File(name);
                   while ((! fileObject.exists()) || ( ! fileObject.canRead()))
                        if( ! fileObject.exists())
                             System.out.println("No such file");
                        else
                             System.out.println("That file is not readable.");
                             System.out.println("Enter file name again:");
                             name = keyboard.next();
                             fileObject = new File(name);                    
              public static void displayResults()
                   System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                   System.out.println("*Average (rounded) product ratings, by income bracket, are as follows: ");
                   System.out.println(myData.toString());
                   System.out.print("\n*Total number of persons in Income Bracket $50000-$74999 ");
                   System.out.print("that rated all three products with a score of 5 ");
                   System.out.println("or higher: " + myData.getHighRaters());
                   System.out.print("\n*Average (rounded) rating for Product 2 by ");
                   System.out.println("persons who rated Product 1 lower than Product 3: " + myData.rating2ave1lower3);
    }Here is the backup class (just for your reference):
    import java.util.*;
    import java.io.*;
    class ProductData
              private String name;
              private int lineCount;
              private double inc1total;
              private double inc2total;
              private double inc3total;
              private int rating1totalLow;
              private int rating2totalLow;
              private int rating3totalLow;
              private int rating1totalMed;
              private int rating2totalMed;
              private int rating3totalMed;
              private int rating1totalHigh;
              private int rating2totalHigh;
              private int rating3totalHigh;
              private int highRaters;
              private double lower1than3Total;
              private int rating2lower1than3;
              private long rating2ave1lower3;
              private long rating1averageLow;
              private long rating2averageLow;
              private long rating3averageLow;
              private long rating1averageMed;
              private long rating2averageMed;
              private long rating3averageMed;
              private long rating1averageHigh;
              private long rating2averageHigh;
              private long rating3averageHigh;
              public ProductData()
                   name = null;
                   lineCount = 0;
                   inc1total = 0;
                   inc2total = 0;
                   inc3total = 0;
                   rating1totalLow = 0;
                   rating2totalLow = 0;
                   rating3totalLow = 0;
                   rating1totalMed = 0;
                   rating2totalMed = 0;
                   rating3totalMed = 0;
                   rating1totalHigh = 0;
                   rating2totalHigh = 0;
                   rating3totalHigh = 0;
                   highRaters = 0;
                   lower1than3Total= 0;
                   rating2lower1than3 = 0;
                   rating1averageLow = 0;
                   rating2averageLow = 0;
                   rating3averageLow = 0;
                   rating1averageMed = 0;
                   rating2averageMed = 0;
                   rating3averageMed = 0;
                   rating1averageHigh = 0;
                   rating2averageHigh = 0;
                   rating3averageHigh = 0;     
              public void setName(String newName)
                   String name = newName;
              public void dataRetrieve(String name)
                   try
                        BufferedReader inputStream = new BufferedReader(new FileReader(name));
                        String trash = "No trash yet";
                        while ((trash = inputStream.readLine()) !=null)
                             StringTokenizer st = new StringTokenizer(trash);
                             int income = Integer.parseInt(st.nextToken());
                             int rating1 = Integer.parseInt(st.nextToken());
                             int rating2 = Integer.parseInt(st.nextToken());
                             int rating3 = Integer.parseInt(st.nextToken());
                             if(rating1<rating3)
                                  lower1than3Total++;
                                  rating2lower1than3 = rating2lower1than3 + rating2;
                             if(income<50000)
                                  rating1totalLow = rating1totalLow + rating1;
                                  rating2totalLow = rating2totalLow + rating2;
                                  rating3totalLow = rating3totalLow + rating3;
                                  inc1total++;
                             else if(income<75000)
                                  rating1totalMed = rating1totalMed + rating1;
                                  rating2totalMed = rating2totalMed + rating2;
                                  rating3totalMed = rating3totalMed + rating3;
                                  inc2total++;
                                  if((rating1>=5) && (rating2>=5) && (rating3>=5))
                                       highRaters++;
                             else if(income<100000)
                                  rating1totalHigh = rating1totalHigh + rating1;
                                  rating2totalHigh = rating2totalHigh + rating2;
                                  rating3totalHigh = rating3totalHigh + rating3;
                                  inc3total++;
                             lineCount++;
                        inputStream.close();
                   catch(IOException e)
                        System.out.println("Problem reading from file.");
              public void updateAverages(int rating1totalLow, int rating2totalLow, int rating3totalLow, int rating1totalMed, int rating2totalMed, int rating3totalMed, int rating1totalHigh, int rating2totalHigh, int rating3totalHigh, long inc1total, long inc2total, long inc3total)
                   rating1averageLow = Math.round(rating1totalLow/inc1total);
                   rating2averageLow = Math.round(rating2totalLow/inc1total);
                   rating3averageLow = Math.round(rating3totalLow/inc2total);
                   rating1averageMed = Math.round(rating1totalMed/inc2total);
                   rating2averageMed = Math.round(rating2totalMed/inc2total);
                   rating3averageMed = Math.round(rating3totalMed/inc2total);
                   rating1averageHigh = Math.round(rating1totalHigh/inc3total);
                   rating2averageHigh = Math.round(rating2totalHigh/inc3total);
                   rating3averageHigh = Math.round(rating3totalHigh/inc3total);
              public long setRating2ave1lower3(int rating2lower1than3, double lower1than3Total)
                   long rating2ave1lower3 = (rating2lower1than3/lower1than3Total);
                   return rating2ave1lower3;
              public String toString()
                   return ("\nIncome level $26000-$49999:" + "\n" + "-Product 1: "
                         + rating1AverageLow + "-Product 2: " + rating2AverageLow
                         + "-Product 3: " + rating3AverageLow + "\n" + "\n" + "Income level $50000-$74999:" + "\n" + "-Product 1: "
                         + rating1AverageMed + "-Product 2: " + rating2AverageMed
                         + "-Product 3: " + rating3AverageMed + "\n" + "\n" + "Income level $75000-$100000:" + "\n" + "-Product 1: "
                         + rating1AverageHigh + "-Product 2: " + rating2AverageHigh
                         + "-Product 3: " + rating3AverageHigh);
              public int getHighRaters()
                   return highRaters;
    }

    You're trying to define those methods inside another method (the "main" method, in this case). Don't do that.

  • Invalid start of expression error

    This is my first post, so I hope this is the right section.
    I am trying to do an if statement to check for a flush in my poker game and I am getting an "Illegal start of expression " error.
    Here is the loop:
    for (int i = 0; i < numPlayers; i++)
                if ((bestHands[0].getSuit() == bestHands[i][1].getSuit())&&(bestHands[i][0].getSuit() == bestHands[i][2].getSuit()) && (bestHands[i][0].getSuit()) == bestHands[i][3].getSuit()) && (bestHands[i][0].getSuit() == bestHands[i][4].getSuit())
    flush = true;
    Any help would be appreciated

    Yea, I did.
    Here is the fixed code:
    for (int i = 0; i < numPlayers; i++)
                if ((bestHands[0].getSuit() == bestHands[i][1].getSuit())&&(bestHands[i][0].getSuit() == bestHands[i][2].getSuit()) && (bestHands[i][0].getSuit() == bestHands[i][3].getSuit()) && (bestHands[i][0].getSuit() == bestHands[i][4].getSuit()))
    flush = true;

  • Compile error "illegal start of expression"

    ok. so i have to make methods for a scrabble calculator applet, and just can't seem to get it right. this is my code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class scrabbleScore extends JApplet
        implements ActionListener
         * Make a text box
        private JPanel display;
        private JTextField word;
        private JLabel number;
        private JLabel d;
        String s = "Type word here, then hit Enter";
        String e = "|";
        String f, c = " ";
        int scr = 0;
        String str[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
        int score[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 3, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};
        public void init(){
            //Make text box
            word = new JTextField (
                        "Type word here, then hit Enter", 20);
            word.setBackground(Color.white);
            word.setEditable(true);
            word.addActionListener(this);
            word.selectAll();
            word.requestFocus();
            //Draw the # box
            number = new JLabel("# Appears here");
            d = new JLabel("Letter values appear here");
            //Draw the pane
            Container c = getContentPane();
            c.setLayout(new FlowLayout());
            c.add(word);
            c.add(d);
            c.add(number);
        public void actionPerformed(ActionEvent e){
             * check if word has text
            JTextField word = (JTextField)e.getSource();
            String w = word.getText();
            w = w.toUpperCase();
            w = w.trim();
            if (validateData(w) == true) {
                JOptionPane.showMessageDialog(this,
                    "You have not entered a valid word", "Error", JOptionPane.ERROR_MESSAGE);
            else {
                d.setText(wordValue(w));
                number.setText("|| Value = " + computeScore(w) + " ||");
            Boolean validateData(String w){
                while (w.compareToIgnoreCase(s) != 0) {
                    return false;
                return true;
        //Method computeScore(String word)
        String computeScore(String w){
             *Put word in an array
            String wrd[] = new String[w.length()];
            for (int i = 0; i < w.length(); i++) {
                wrd[i] = w.charAt(i) + "";
            for (int i = 0; i < wrd.length; i++) {
                String y = wrd;
    int k = y.getValue();
    scr += score[k];
    public int getValue(String y) {
    int num = 0;
    String z = str[num];
    while (y.compareTo(z) != 0) {
    num++;
    z = str[num];
    return num;
    //Return v to set text
    String v = scr + "";
    scr = 0;
    return v;
    String wordValue(String w){
    char wrd[] = new char[w.length()];
    for (int i = 0; i < w.length(); i++) {
    wrd[i] = w.charAt(i);
    for (int i = 0; i < wrd.length; i++) {
    int value = Character.getNumericValue(wrd[i]);
    value -= 10;
    String a = " " + wrd[i] + " ";
    c = "|" + a + "= " + score[value] + "|";
    e = e + c;
    f = e + "| ==>";
    c = "";
    e = "|";
    return f;
    }and i get an "illegal start or expression" compile error at the line public int getValue(String y). Does anyone know how i could fix this?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Just so you guys can see it if you want to, here's my finished code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class scrabbleScore extends JApplet
        implements ActionListener
         * Make a text box
        private JPanel display;
        private JTextField word;
        private JLabel number;
        private JLabel d;
        String s = "Type word here, then hit Enter";
        String e = "|";
        String f, c = " ";
        int scr = 0;
        String str[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
        int score[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 3, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};
        public void init(){
            //Make text box
            word = new JTextField (
                        "Type word here, then hit Enter", 20);
            word.setBackground(Color.white);
            word.setEditable(true);
            word.addActionListener(this);
            word.selectAll();
            word.requestFocus();
            //Draw the # box
            number = new JLabel("# Appears here");
            d = new JLabel("Letter values appear here");
            //Draw the pane
            Container c = getContentPane();
            c.setLayout(new FlowLayout());
            c.add(word);
            c.add(d);
            c.add(number);
        public void actionPerformed(ActionEvent e){
             * check if word has text
            JTextField word = (JTextField)e.getSource();
            String w = word.getText();
            w = w.toUpperCase();
            w = w.trim();
            if (validateData(w) == true) {
                JOptionPane.showMessageDialog(this,
                    "You have not entered a valid word", "Error", JOptionPane.ERROR_MESSAGE);
            else {
                String[] wrd = makeArray(w);
                d.setText(wordValue(w, wrd));
                number.setText("|| Value = " + computeScore(w, wrd) + " ||");
                resetValues();
            Boolean validateData(String w){
                while (w.compareToIgnoreCase(s) != 0) {
                    return false;
                return true;
        //Method getValue
        int getValue(String y) {
            int num = 0;
            String z = str[num];
            while (y.compareTo(z) != 0) {
                num++;
                z = str[num];
            return num;
        //Method makeArray
        String[] makeArray(String w) {
            String wrd[] = new String[w.length()];
            for (int i = 0; i < w.length(); i++) {
                wrd[i] = w.charAt(i) + "";
               return wrd;
        //method makeLetterValues
        String makeLetterValues(String[] wrd, int i, int value) {
            String a = " " + wrd[i] + " ";
            c = "|" + a + "= " + score[value] + "|";
            e = e + c;
            return e;
        //method resetValues
        void resetValues() {
            c = "";
            e = "|";
            scr = 0;
        //Method computeScore(String word)
        String computeScore(String w, String[] wrd){
            //get score
            for (int i = 0; i < wrd.length; i++) {
                String y = wrd;
    int k = getValue(y);
    scr += score[k];
    //Return v to set text
    String v = scr + "";
    return v;
    //method wordValue
    String wordValue(String w, String[] wrd){
    //make letter value string
    for (int i = 0; i < wrd.length; i++) {
    int value = getValue(wrd[i]);
    String e = makeLetterValues(wrd, i, value);
    f = e + "| ==>";
    return f;

  • Illegal start of type error when adding for loop to applet

    I have typed the following applet to print a horizontal row of stars with the length entered by the user (i.e. user enters 4 and applet prints out 4 stars in a row). Here is my code:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
           String input = "";
            int number;
         public void init()
              input = JOptionPane.showInputDialog ( null,
              "Enter a number\nbetween 1 and 30:" );
              number = Integer.parseInt( input );
         public void paint ( Graphics g )
              for ( int counter = 1; counter <= number; counter++ )
                                    System.out.print( "*" );
               System.out.println();
    };Now I am trying to make it do this 5 times, so it seems like just surrounding the init and paint methods in a for loop (i.e. for ( int i=1; i <= 5; i++ ) ) would do the trick but when I do that I get an illegal start of type error when trying to compile. Does anyone know why this error would show up. The most common reply to questions of this sort seems to be to check the closing braces but I have checked very carefully after adding the for loop and don't see any problems with mismatched braces. Could you please help me get on the right track as to how I can make this applet print a horizontal row of stars five times? All help is appreciated.

    Hello JTMOBOP:
    You were correct in figuring that I was trying to get the applet to print five rows of stars of different length according to five different inputs from the user. I tried your suggestions, and the code now does compile and run, but it still does not run properly (i.e. only asks user once for input and displays row of stars but does not show an input dialog again). Here is the code I have retyped:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
       String input = "";
       int[] number = new int[5];
       public void init()
          for ( int i = 0; i < 5; i++ )
             input = JOptionPane.showInputDialog ( null,
                "Enter a number\nbetween 1 and 30:" );
             number[i] = Integer.parseInt( input );
       public void paint ( Graphics g )
          for ( int i = 0; i < 5; i++ )
             for ( int myNumber = 0; myNumber <= number; myNumber++ )
    System.out.print( "*" );
    System.out.println();
    Any ideas what's going on here?
    Also, your comments about not being able to loop a method make sense. Thank you for the input so far.

  • Illegal start to expression - java applet

    Hi Guys,
    this code is for a hangman game which will be in an applet. When I try putting the buttons in init, I'm getting an "illegal start of expression" for each button. Can someone tell me what I'm doing wrong?
    Cheers,
    * @(#)Hangman.java
    * Sample Applet application
    * @author
    * @version 1.00 06/10/17
    import java.util.Random;
    import java.util.*;
    import java.awt.*;
    import java.applet.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    public class Hangman extends JApplet implements ActionListener
         Scanner textfile =new Scanner ("list.txt"); //file with words in
         int count=0;//count number of letters in chosen word
         int lives=6;//lives left
         String [] list= new String [count]; //word chosen stored in array
         boolean [] listDisplay=new boolean [count]; //whether letters in word have been guessed correct
         String guess=null; //guess
         boolean cont=false; //whether game continues or not
         public void read()
              try
                   while (textfile.hasNext()==true)
                        count++;
                   for (int i=0;i<count;i++)
                        String input=null;
                        list=input;
              catch (InputMismatchException e)
              System.out.println ("Mismatch exception:" + e );
         public String selectWord()
              int index=0;
              Random ind=new Random();
              String word=null;
              index=ind.nextInt();
              word=list[index];
              return word;
         public void wrongGuess(int lives)
              switch (lives)
                   case 6:               
                   break;
                   case 5:
                   break;
                   case 4:
                   break;
                   case 3:
                   break;
                   case 2:
                   break;
                   case 1:
                   break;
                   case 0:
                   cont=false;     
         public void game()
              String word=null;
              read();
              word=selectWord();
              while (cont==true)
         public void check(String letter)
              boolean tried=false;
              for (int i=0;i<list.length;i++)
                   if (list[i]==letter)
                        listDisplay[i]=true;
                   else
                        if (tried==false)
                             lives--;
                             tried=true;//guard to stop multiple lives lost by 1 letter
         public void init()
              //setup buttons
              private JButton jbtA=new JButton("A");
              private JButton jbtB=new JButton("B");
              private JButton jbtC=new JButton("C");
              private JButton jbtD=new JButton("D");
              private JButton jbtE=new JButton("E");
              private JButton jbtF=new JButton("F");
              private JButton jbtG=new JButton("G");
              private JButton jbtH=new JButton("H");
              private JButton jbtI=new JButton("I");
              private JButton jbtJ=new JButton("J");
              private JButton jbtK=new JButton("K");
              private JButton jbtL=new JButton("L");
              private JButton jbtM=new JButton("M");
              private JButton jbtN=new JButton("N");
              private JButton jbtO=new JButton("O");
              private JButton jbtP=new JButton("P");
              private JButton jbtQ=new JButton("Q");
              private JButton jbtR=new JButton("R");
              private JButton jbtS=new JButton("S");
              private JButton jbtT=new JButton("T");
              private JButton jbtU=new JButton("U");
              private JButton jbtV=new JButton("V");
              private JButton jbtW=new JButton("W");
              private JButton jbtX=new JButton("X");
              private JButton jbtY=new JButton("Y");
              private JButton jbtZ=new JButton("Z");
              JPanel p1=new JPanel();
              p1.add(jbtA);
              p1.add(jbtB);
              p1.add(jbtC);
              p1.add(jbtD);
              p1.add(jbtE);
              p1.add(jbtF);
              p1.add(jbtG);
              p1.add(jbtH);
              p1.add(jbtI);
              p1.add(jbtJ);
              p1.add(jbtK);
              p1.add(jbtL);
              p1.add(jbtM);
              p1.add(jbtN);
              p1.add(jbtO);
              p1.add(jbtP);
              p1.add(jbtQ);
              p1.add(jbtR);
              p1.add(jbtS);
              p1.add(jbtT);
              p1.add(jbtU);
              p1.add(jbtV);
              p1.add(jbtW);
              p1.add(jbtX);
              p1.add(jbtY);
              p1.add(jbtZ);
              getContentPane().add(p1,BorderLayout.CENTER);
         public void start()
              game();
         public void paint(Graphics g)
              g.drawString("Welcome to Java!!", 50, 60 );
         public void actionPerformed(ActionEvent e)
              if (e.getSource()==jbtA)
                   check("A");
              if (e.getSource()==jbtB)
                   check("B");
              if (e.getSource()==jbtC)
                   check("C");
              if (e.getSource()==jbtD)
                   check("D");
              if (e.getSource()==jbtE)
                   check("E");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtG)
                   check("G");
              if (e.getSource()==jbtH)
                   check("H");
              if (e.getSource()==jbtI)
                   check("I");
              if (e.getSource()==jbtJ)
                   check("J");
              if (e.getSource()==jbtK)
                   check("K");
              if (e.getSource()==jbtL)
                   check("L");
              if (e.getSource()==jbtM)
                   check("M");
              if (e.getSource()==jbtN)
                   check("N");
              if (e.getSource()==jbtO)
                   check("O");
              if (e.getSource()==jbtP)
                   check("P");
              if (e.getSource()==jbtQ)
                   check("Q");
              if (e.getSource()==jbtR)
                   check("R");
              if (e.getSource()==jbtS)
                   check("S");
              if (e.getSource()==jbtT)
                   check("T");
              if (e.getSource()==jbtU)
                   check("U");
              if (e.getSource()==jbtV)
                   check("V");
              if (e.getSource()==jbtW)
                   check("W");
              if (e.getSource()==jbtX)
                   check("X");
              if (e.getSource()==jbtY)
                   check("Y");
              if (e.getSource()==jbtZ)
                   check("Z");
    /code]

    cheers for the reply :)
    I've managed to compile the file, but nothing is displayed. I'm compiling using JDK 5. Any ideas?
    * @(#)Hangman.java
    * Sample Applet application
    * @author
    * @version 1.00 06/10/17
    import java.util.Random;
    import java.util.*;
    import java.awt.*;
    import java.applet.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.BorderLayout;
    public class Hangman extends JApplet implements ActionListener
         Scanner textfile =new Scanner ("list.txt"); //file with words in
         int count=0;//count number of letters in chosen word
         int lives=6;//lives left
         String [] list= new String [count]; //word chosen stored in array
         boolean [] listDisplay=new boolean [count]; //whether letters in word have been guessed correct
         String guess=null; //guess
         boolean cont=false; //whether game continues or not
         JButton jbtA;
         JButton jbtB;
         JButton jbtC;
         JButton jbtD;
         JButton jbtE;
         JButton jbtF;
         JButton jbtG;
         JButton jbtH;
         JButton jbtI;
         JButton jbtJ;
         JButton jbtK;
         JButton jbtL;
         JButton jbtM;
         JButton jbtN;
         JButton jbtO;
         JButton jbtP;
         JButton jbtQ;
         JButton jbtR;
         JButton jbtS;
         JButton jbtT;
         JButton jbtU;
         JButton jbtV;
         JButton jbtW;
         JButton jbtX;
         JButton jbtY;
         JButton jbtZ;
         public void read()
              try
                   while (textfile.hasNext()==true)
                        count++;
                   for (int i=0;i<count;i++)
                        String input=null;
                        list=input;
              catch (InputMismatchException e)
              System.out.println ("Mismatch exception:" + e );
         public String selectWord()
              int index=0;
              Random ind=new Random();
              String word=null;
              index=ind.nextInt();
              word=list[index];
              return word;
         public void wrongGuess(int lives)
              switch (lives)
                   case 6:               
                   break;
                   case 5:
                   break;
                   case 4:
                   break;
                   case 3:
                   break;
                   case 2:
                   break;
                   case 1:
                   break;
                   case 0:
                   cont=false;     
         public void game()
              String word=null;
              read();
              word=selectWord();
              while (cont==true)
         public void check(String letter)
              boolean tried=false;
              for (int i=0;i<list.length;i++)
                   if (list[i]==letter)
                        listDisplay[i]=true;
                   else
                        if (tried==false)
                             lives--;
                             tried=true;//guard to stop multiple lives lost by 1 letter
         public void init()
              //setup buttons
              jbtA=new JButton("A");
              jbtB=new JButton("B");
              jbtC=new JButton("C");
              jbtD=new JButton("D");
              jbtE=new JButton("E");
              jbtF=new JButton("F");
              jbtG=new JButton("G");
              jbtH=new JButton("H");
              jbtI=new JButton("I");
              jbtJ=new JButton("J");
              jbtK=new JButton("K");
              jbtL=new JButton("L");
              jbtM=new JButton("M");
              jbtN=new JButton("N");
              jbtO=new JButton("O");
              jbtP=new JButton("P");
              jbtQ=new JButton("Q");
              jbtR=new JButton("R");
              jbtS=new JButton("S");
              jbtT=new JButton("T");
              jbtU=new JButton("U");
              jbtV=new JButton("V");
              jbtW=new JButton("W");
              jbtX=new JButton("X");
              jbtY=new JButton("Y");
              jbtZ=new JButton("Z");
              JPanel p1=new JPanel();
              p1.add(jbtA);
              p1.add(jbtB);
              p1.add(jbtC);
              p1.add(jbtD);
              p1.add(jbtE);
              p1.add(jbtF);
              p1.add(jbtG);
              p1.add(jbtH);
              p1.add(jbtI);
              p1.add(jbtJ);
              p1.add(jbtK);
              p1.add(jbtL);
              p1.add(jbtM);
              p1.add(jbtN);
              p1.add(jbtO);
              p1.add(jbtP);
              p1.add(jbtQ);
              p1.add(jbtR);
              p1.add(jbtS);
              p1.add(jbtT);
              p1.add(jbtU);
              p1.add(jbtV);
              p1.add(jbtW);
              p1.add(jbtX);
              p1.add(jbtY);
              p1.add(jbtZ);
              getContentPane().add(p1,BorderLayout.CENTER);
         public void start()
              game();
         public void paint(Graphics g)
              g.drawString("Welcome to Java!!", 50, 60 );
         public void actionPerformed(ActionEvent e)
              if (e.getSource()==jbtA)
                   check("A");
              if (e.getSource()==jbtB)
                   check("B");
              if (e.getSource()==jbtC)
                   check("C");
              if (e.getSource()==jbtD)
                   check("D");
              if (e.getSource()==jbtE)
                   check("E");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtF)
                   check("F");
              if (e.getSource()==jbtG)
                   check("G");
              if (e.getSource()==jbtH)
                   check("H");
              if (e.getSource()==jbtI)
                   check("I");
              if (e.getSource()==jbtJ)
                   check("J");
              if (e.getSource()==jbtK)
                   check("K");
              if (e.getSource()==jbtL)
                   check("L");
              if (e.getSource()==jbtM)
                   check("M");
              if (e.getSource()==jbtN)
                   check("N");
              if (e.getSource()==jbtO)
                   check("O");
              if (e.getSource()==jbtP)
                   check("P");
              if (e.getSource()==jbtQ)
                   check("Q");
              if (e.getSource()==jbtR)
                   check("R");
              if (e.getSource()==jbtS)
                   check("S");
              if (e.getSource()==jbtT)
                   check("T");
              if (e.getSource()==jbtU)
                   check("U");
              if (e.getSource()==jbtV)
                   check("V");
              if (e.getSource()==jbtW)
                   check("W");
              if (e.getSource()==jbtX)
                   check("X");
              if (e.getSource()==jbtY)
                   check("Y");
              if (e.getSource()==jbtZ)
                   check("Z");

  • An illegal start of expression!

    Hi, A fairly simple question. trying to call a method from the same class gives me an illegal start of expression error. Any ideas how to sort it out.
    methodname(); //thats how i am calling the method.
    public void methodname() //this is my method
    rubbish in it
    Thanks

    Here is the code, I cannot spot what is causing it.
    //<-----------------CODE---------------------->
    import java.io.*;
    class TempConvert
    public static void main(String args[]) throws IOException {  
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("***Temperature Convertor***");
    System.out.println("to Convert from Fahrenheit to Celcius enter 1");
    System.out.println("to Convert from Celcius to Fahrenheit enter 2");
    String choice = in.readLine();
    int Choice = Integer.parseInt(choice);
    if (Choice == 1)
    Celcius(); //A Call to Celcius Method
    else if (Choice == 2)
    Fahrenheit(); //A Call to Fahrenheit Method
    else
    System.out.println("You have entered an invalid number --Please try again");
    //Celcius Method
    public void Celcius()
    System.out.print("Enter the City: ");
    String city = in.readLine();
    System.out.print("Enter the Temperature in Degree Fahrenheit: ");
    String fahrenheit = in.readLine();
    double degreeF = Integer.parseInt(fahrenheit);
    double degreeC = ((degreeF* 9/5) + 32);
    System.out.print("The temperature in Degree Celcius for " + city);
    System.out.println(" is " + degreeC);
    //Fahrenheit Method
    public void Fahrenheit()
    System.out.print("Enter the City: ");
    String city = in.readLine();
    System.out.print("Enter the Temperature in Degree Celcius: ");
    String celcius = in.readLine();
    double degreeC = Integer.parseInt(celcius);
    double degreeF = ((degreeC - 32) * 5/9);
    System.out.print("The temperature in Degree Fahrenheit for " + city);
    System.out.println(" is " + degreeF);
    System.out.println("***Thanks for using the Temperature Convertor!***");
    System.exit(0);
    //<---------------------END CODES --------------------->
    Thanks

  • On my Mac Pro how can I get voiceover to start reading at a specific point on a document?, on my Mac Pro how can I get voiceover to start reading at a specific point on a document?

    On my Mac Pro how can I get voiceover to start reading at a specific point in a document, and then continue on to the next paragraph and so on?  Thank you.  Ed

    Welcome to the Apple family!!!! 
    How can I cause the VO cursor(box) show-up/start?
    Press Control-Option and F5.   The F5 key is located on the top row of keys 6th key over.  This is a toggling "Keyboard Shortcut" for turning VoiceOver on and off.
    How can I move the VO cursor to various sentences or paragraphs of an article and have it start reading ... and perhaps even continue reading on to the next paragraph(s) ... even to the end of the article?
    How to read a website with VoiceOver
    Step 1:  Go to the Website
    A quick keyboard shortcut is Command-L.  This will jump you up to the address bar.  Start typing where you want to go.  i.e "www.thewebsite.com"
    Step 2:  Working with Webpage
    VoiceOver will automatically start reading the website.  You can pause the speech by hitting the 'Control Button'. 
    If VoiceOver does not being reading the webpage, then you might have to "Interact" with it.  If VoiceOver say "HTML Content" then press Control-Option-Space-Down Arrow to interact with the webpage.
    Use Control-Option-Right Arrow to move throught the website.  This will speak "EVERYTHING" on the page.
    Most website that I've found have their articles labeled as 'Heading'.  You can jump from heading to heading, by pressing Control-Option-Shift-H.
    If you'd like an itemized alphabetical listing of the site, press Control-Option-I 
    Press Control-Option-Space on the link or article you want to view.
    Step 3.  Reading from Top to Bottom
    Once you found and clicked on the the article/link, use the same 'Heading' command, Control-Option-Shift-H to find the title. 
    After finding the title, press Control-Option-A will start reading from the title on. 
    Note:  If there are any other items (ads, pictures, etc) it will read those too. 
    Tip:  You might be able to activate a feature called the 'Reader'.  The Reader isolates the article and elimanates the ads  The keyboard command is Shift-Command-R.  You can also find it in the Menu Bar (Command-Option-M) under the word 'View' then 'Show Reader'. 
    I am using a MACPro with OSX, probably Mavericks 10.9 (where would I look to see if that is the correct information?)
    You can find this information under the 'Apple menu' in the Menu Bar.  To access the Menu Bar, press Control-Option-M. 
    Go to Apple Menu > About This Mac.  This will open up another window.  Use Control-Option-Right Arrow until you hear 'Version'.  If you purchased it brand new from Apple within the last six month, more than likely you have Mavericks. 
    Recommanded Articles. 
    AppleVis- Commonly used Keyboard Commands
    Chapter 2: Learning VoiceOver Basics
    Chapter 6: Browsing the internet
    Apple Accessibility Resource Page
    The  'Commands Help' Voiceover Menu. Control-Option-H-H.  (hit H twice)  is my best friend.  It's a searchable VoiceOver Menu with most of the VoiceOver command.  Example:  You are looking for the 'Read Current Paragraph' keyboard command.   Press Control-Option-H-H and then type Paragraph.  It will then bring up all the commands with the word paragraph.  I believe there are three.   
    As from the Trackpad Commands, I've copied and pasted below from Appendix A: Commands and Gestures
    VoiceOver standard gestures
    If you’re using a Multi-Touch trackpad, you can use VoiceOver gestures. VoiceOver provides a set of standard gestures for navigating and interacting with items on the screen. You can’t modify this set of gestures.
    NOTE:Gestures that don’t mention a specific number of fingers are single-finger gestures.
    General
    Enable the Trackpad Commander and VoiceOver gestures
    VO-Two-finger rotate clockwise
    Disable the Trackpad Commander and VoiceOver gestures
    VO-Two-finger rotate counterclockwise
    Turn the screen curtain on or off
    Three-finger triple-tap
    Mute or unmute VoiceOver
    Three-finger double-tap
    Navigation
    Force the VoiceOver cursor into a horizontal or vertical line when you drag a finger across the trackpad
    Hold down the Shift key and drag a finger horizontally or vertically
    Move the VoiceOver cursor to the next item
    Flick right
    Move the VoiceOver cursor to the previous item
    Flick left
    Move content or the scroll bar (depending on the Trackpad Commander setting)
    Three-finger flick in any direction
    Go to the Dock
    This gesture moves the VoiceOver cursor to the Dock wherever it’s positioned on the screen
    Two-finger double-tap near the bottom of the trackpad
    Go to the menu bar
    Two-finger double-tap near the top of the trackpad
    Open the Application Chooser
    Two-finger double-tap on the left side of the trackpad
    Open the Window Chooser
    Two-finger double-tap on the right side of the trackpad
    Jump to another area of the current application
    Press Control while touching a finger on the trackpad
    Interaction
    Speak the item in the VoiceOver cursor or, if there isn’t an item, play a sound effect to indicate a blank area
    Touch (includes tap or dragging)
    Select an item
    Double-tap anywhere on the trackpad
    You can also split-tap (touch one finger and then tap with a second finger on the trackpad)
    Start interacting with the item in the VoiceOver cursor
    Two-finger flick right
    Stop interacting with the item in the VoiceOver cursor
    Two-finger flick left
    Scroll one page up or down
    Three-finger flick up or down
    Escape (close a menu without making a selection)
    Two-finger scrub back and forth
    Increase or decrease the value of a slider, splitter, stepper, or other control
    Flick up (increase) or flick down (decrease)
    Text
    Read the current page, starting at the top
    Two-finger flick up
    Read from the VoiceOver cursor to the end of the current page
    Two-finger flick down
    Pause or resume speaking
    Two-finger tap
    Describe what’s in the VoiceOver cursor
    Three-finger tap
    Change how VoiceOver reads text (by word, line, sentence, or paragraph)
    Press the Command key while touching a finger on the trackpad
    Rotor
    Change the rotor settings
    Two-finger rotate
    Move to the previous item based on the rotor setting
    Flick up
    Move to the next item based on the rotor setting
    Flick down
    To customize other gestures by assigning VoiceOver commands to them, use the Trackpad Commander.
    Assigning VoiceOver commands to gestures
    If you need a reminder about what a gesture does, press VO-K to start keyboard help, and then use the gesture on the trackpad and listen to the description.
    Learning about keys, keyboard shortcuts, and gestures
    Sorry lots of information.  Enjoy.  You

  • After installing the latest version of ITunes I get an error message that says this application has failed to start because MSVCR80.dll was not found.  how do I get Itunes to start working again?

    After installing the latest version of ITunes I get an error message that says this application has failed to start because MSVCR80.dll was not found.  how do I get Itunes to start working again?

    See... Unable to install or open > http://support.apple.com/kb/TS5376
    Also See this User Tip by turingtest2
    https://discussions.apple.com/docs/DOC-6562

  • I bought mountain lion for my macbook pro and I'm trying to install it and it says there was an error and I need to boot up but I don't have any other start up disks to boot up with. Are there any suggestions of how I could get my computer started?

    I bought mountain lion for my macbook pro and I'm trying to install it and it says there was an error and I need to boot up but I don't have any other start up disks to boot up with. Are there any suggestions of how I could get my computer started?

    Hold the Option key down and restart. Select one of the drives that comes up and hit the Return key.

  • How do I get to the start of a really long text message conversation without scrolling through them all? Thanks

    Hi. How do I get to the start of a really long text message conversation without having to scroll through and load earlier messages repeatedly?  Thanks

    click on the top of the screen (the top bar/clock sectionish).  Hope i helped

  • The movie I rented on iTunes has stopped right in the middle of the movie because it hasn't finished loaded.  How do I get it to start playing again before the rental expires?

    The movie I rented on iTunes has stopped right in the middle of the movie because it hasn't finished loaded.  How do I get it to start playing again before the rental expires?

    Hello zooeyme,
    I'd suggest reporting the issue to the folks in our iTunes Store.
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/HT1933
    Cheers,
    Allen

  • My sent messages in outlook for mac suddenly stopped syncing with my iPhone and iPad, all other folders work correctly. How can I get them to start syncing again?

    My sent messages in outlook for mac suddenly stopped syncing with my iPhone and iPad, all other folders work correctly. How can I get them to start syncing again?

    You can disable the Adobe Reader plugin in Firefox (Tools > Add-ons > Plugins) and use the external Adobe Reader application or Preview application instead.
    *Firefox > Preferences > Applications > Adobe PDF document : Use Adobe Reader
    PDF files may also be found under another entry like Portable document.
    *https://support.mozilla.org/kb/change-firefox-behavior-when-open-file

  • How can I get i messages started

    How can I get I messages started? I've already signed but I am not able to send messages to people. Pleas help me

    the send button is grey and I can't send any thing

Maybe you are looking for