Plz tell me wht is error in  code.its showing illegal start of expression

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
class Image01 extends Frame{ //controlling class
  Image rawImage;    //ref to raw image file fetched from disk
  Image modImage;      //ref to modified image
  int rawWidth;
  int rawHeight;
  int inTop;           //Inset values for the container object
  int inLeft; 
   public static void main(String[] args)     {
         Image01 obj = new Image01();                 //instantiate this object
        obj.repaint();                              //render the image
       }                                           //end main
  public Image01()
   {                                          //constructor
                                                  //Get an image from the specified file in the current directory on the local hard disk.
    rawImage =    Toolkit.getDefaultToolkit().getImage("myco.jpeg");
    MediaTracker tracker = new MediaTracker(this);
    tracker.addImage(rawImage,1);
   try{                                         //because waitForID throws InterruptedException
  if(!tracker.waitForID(1,10000))
        System.out.println("Load error.");
        System.exit(1);       
   catch(InterruptedException e)
      System.out.println(e);  }
        this.setVisible(true);//make the Frame visible
      rawWidth = rawImage.getWidth(this);               //Raw image has been loaded.  Establish width and
    rawHeight = rawImage.getHeight(this);            // height of the raw image.
    inTop = this.getInsets().top;                    //Get and store inset data for the Frame object so
    inLeft = this.getInsets().left;                 // that it can be easily avoided.
      this.setSize(800,800);
    //this.setSize(inLeft+rawWidth,inTop+2*rawHeight);        //Use the insets and the size of the raw image to
    this.setTitle("Copyright 1997, Baldwin");                // establish the overall size of the Frame object. 
    this.setBackground(Color.yellow);                        //Make the Frame object twice the height of the
                                                             // image so that the raw image and the modified image
                                                            // can both be rendered on the Frame object.
    public void handlepixels(Image rawImage,int x,int y,int  rawWidth, int rawHeight)
    int[] pix = new int[rawWidth * rawHeight];              //Declare an array object to receive the pixel
                                                         // representation of the image
   //Convert the rawImage to numeric pixel representation
   try
     PixelGrabber pgObj = new PixelGrabber(rawImage,0,0,rawWidth,rawHeight,pix,0,rawWidth);
           if(pgObj.grabPixels() && ((pgObj.getStatus() & ImageObserver.ALLBITS) != 0)    {   
for (int j = 0; j <rawHeight ; j++)     {
                    for (int i = 0; i < rawWidth; i++)        {
                          handlesinglepixel(x+i, y+j, pixels[j * rawWidth + i]);        
                                                        //end if statement
           else System.out.println("Pixel grab not successful")     }
    catch(InterruptedException e)
System.out.println(e);     }
    modImage = this.createImage(new MemoryImageSource(rawWidth,rawHeight,pix,0,rawWidth));          //Use the createImage() method to create a new image
                                                                                                    // from the array of pixel values.s
    this.addWindowListener(new WindowAdapter()                                                      //Anonymous inner-class listener to terminate program
          //anonymous class definition
          public void windowClosing(WindowEvent e)
               System.exit(0);                                                   //terminate the program
          }//end windowClosing()
      }   //end WindowAdapter
    );//end addWindowListener
  }//end constructor 
  //Override the paint method to display both the rawImage
  // and the modImage on the same Frame object.
public void paint(Graphics g)
              if(modImage != null)
                     g.drawImage(rawImage,inLeft+50,inTop+50,this);
                     g.drawImage(modImage,inLeft+50,inTop+rawHeight+100,this);
                        }//end if
       }//end paint()
}//end Image05 class plz tell me the how to remove error

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
class Image01 extends Frame
  Image rawImage;  
  Image modImage; 
  int rawWidth;
  int rawHeight;
  int inTop;        
  int inLeft;
public static void main(String[] args)
         Image01 obj = new Image01();         
        obj.repaint();                             
  public Image01()
               rawImage = Toolkit.getDefaultToolkit().getImage("myco.jpeg");.
               MediaTracker tracker = new MediaTracker(this);
               tracker.addImage(rawImage,1);
        try
           if(!tracker.waitForID(1,10000))
           System.out.println("Load error.");
           System.exit(1);       
       catch(InterruptedException e)
       System.out.println(e);
     this.setVisible(true);
    rawWidth = rawImage.getWidth(this);            
    rawHeight = rawImage.getHeight(this);          
    inTop = this.getInsets().top;                   
    inLeft = this.getInsets().left;                
    this.setSize(800,800);
     public void handlesinglepixel(int x, int y, int pixel)        *// this line is showing error*
     int alpha = (pixel >> 24) & 0xff;
     int red   = (pixel >> 16) & 0xff;
     int green = (pixel >>  8) & 0xff;
     int blue  = (pixel      ) & 0xff;
    public void handlepixels(Image rawImage, int x, int y,  rawWidth,  rawHeight)
           int[] pix = new int[rawWidth * rawHeight];            
                     try
                         PixelGrabber pgObj = new PixelGrabber(rawImage,0,0,rawWidth,rawHeight,pix,0,rawWidth);
                         if(pgObj.grabPixels() && ((pgObj.getStatus() & ImageObserver.ALLBITS) != 0))
                               for (int j = 0; j <rawHeight ; j++)
                                       for (int i = 0; i < rawWidth; i++)
                                                handlesinglepixel(x+i, y+j, pix[j * rawWidth + i]);
                         else System.out.println("Pixel grab not successful");
                 catch(InterruptedException e)
                     System.out.println(e);
          modImage = this.createImage(new MemoryImageSource(rawWidth,rawHeight,pix,0,rawWidth));          
        this.addWindowListener(new WindowAdapter()                                                    
                     public void windowClosing(WindowEvent e)
                            System.exit(0);                                                   
                      }//end windowClosing()
        }   //end WindowAdapter
       );//end addWindowListener
}//end constructor 
  public void paint(Graphics g)
              if(modImage != null)
                     g.drawImage(rawImage,inLeft+50,inTop+50,this);
                     g.drawImage(modImage,inLeft+50,inTop+rawHeight+100,this);
              }//end if
  }//end paint()
}//end Image05 classnow i have deleted all comments & also highlighted the line which is giving error & thanks a lot to all of u who tried to solve my problem but still its showing same error illegal start of expression .if i run this program without handlesinglepixel & handlepixels method its working properly

Similar Messages

  • TS3694 plz tell me about restoring error 1015

    plz tell me about restoring error 1015

    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    Error 1015: This error is typically caused by attempts to downgrade the iPhone, iPad, or iPod touch's software. This can occur when you attempt to restore using an older .ipsw file. Downgrading to a previous version is not supported. To resolve this issue, attempt to restore with the latest iPhone, iPad, or iPod touch software available from Apple. This error can also occur when an unauthorized modification of the iOS has occurred and you are now trying to restore to an authorized, default state.
    You will need to look else where for help if you are attempting to, or have jailbroken your device.

  • 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.

  • 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;

  • Error: illegal start of expression

    Hi, when I compile my program, I get an error that says
    "A6Q1.java:96:illegal start of expression
    public static int IndexOf(int comma) "
    and ^ points to the p in public.
    Here is a copy of the program (CSI1100 is a class that enables the read-in from the keyboard)
    import java.io.* ;
    class A6Q1
    public static void main (String[] args) throws IOException
    // DECLARE VARIABLES/DATA DICTIONARY
         String FullName;     // the string with the full name
         char [] NameArray;     // GIVEN: an array with the full name
         String Abbreviated;     // RESULT: the abbreviated name
    // READ IN GIVENS
         System.out.println("Please enter your full name in the format shown, then press ENTER:");
         System.out.println("<Family name>, <Given name 1> <Given name 2> ...");
         NameArray = CSI1100.readCharLine();
    // BODY OF ALGORITHM
         FullName = new String( NameArray );
         Abbreviated = abbreviate(FullName);
    // PRINT OUT RESULTS AND MODIFIEDS
         System.out.println(Abbreviated);
    // Definitions for the methods used by main go here.
         // METHOD: abbreviate, which will abbreviate people's names from
         // <Family name>, <Given name 1> <Given name 2> ... to
         // <Family name>, <Initial1>. Initial2>. ..., where the full name is given
    public static String abbreviate(String FullName)
         // DECLARE VARIABLES/DATA DICTIONARY
         int Icomma;          // the index at which the comma occurs
         int Ispace;          // the index at which a space occurs
         String Abbreviated;     // the returned result
         int comma;          // the unicode value of a comma
         int space;          // the unicode value of a space
         // BODY OF ALGORITHM
         comma = (int) ',';
         space = (int) ' ';
         Icomma = IndexOf(comma);
         Abbreviated = FullName.substring(0, Icomma+1);
         Ispace = Icomma + 2;
         Abbreviated = Abbreviated + " " + FullName.charAt(Ispace) + ".";
         Ispace = IndexOf2(space, Ispace);
         while (Ispace > (-1))
         if (((int) Ispace) != ((int) Ispace) + 1)
         Ispace = Ispace + 1;
         Abbreviated = Abbreviated + " " + FullName.charAt(Ispace) + ".";
         else
         Ispace = Ispace + 1;
         // RETURN RESULT
         return Abbreviated;
    public static int IndexOf(int comma)
         int Icomma;     // the index at which the comma occurs
         FullName.charAt(Icomma) = comma;
         return Icomma;
    public static int IndexOf2(int space, int Ispace)
         int Icomma;     // the index at which the comma occurs
         int end = -1;     // if there is no comma
         FullName.charAt(Ispace) = space;
         if (Ispace >= Icomma)
         return Ispace;
         else
         return end; //do nothing
    }}

    I'd guess you're missing a } somewhere in there. I'm not going to try checking, because I'm not good at matching up braces which are all aligned on the left. (Hint: in future, when posting code wrap it in &#91;code] ).

  • 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.

  • 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.

  • ERROR MESSAGE: 20: illegal start of expression

    There is something wrong with my program because I have one error and it says "illegal start of expression" and all of my parenthesis and brackets are correct what else is wrong. Here is my program:
    import javax.swing.*;
    import java.util.*;
    public class StudentApp
         public static void main(String [] args) throws NullPointerException
              //declare variables and initialize
              String sID, sName, sHoursStr;
              int choice = 0, sHours, i;
              Student aStudent = Null;
              Vector sVector = new Vector();
              //add objects to Vector
              Vector studentVector = new Vector();
              studentVector = addStudent(studentVector);
              sVector.add(aStudent);
              public static Vector addStudent(Vector sVector)
                   public static Vector addStudent(Vector sVector)
                        sVector.remove(aStudent);
                        aStudent = (Student) sVector.get(i);
                        sID = aStudent.getID();
                        aStudent = (Student) sVector.get(i);
                        sHours = aStudent.getHours();
                   //get objects from a vector and print
                   for(i = 0; i < sVector.size(); i++)
                        aStudent = (String) sVector.get(i);
                        System.out.println(aStudent);
                   //copy vector contents into an Array
                   String [] anArray = new String[sVector.size()];
                   sVector.copyInto(anArray);
                   for(j = 0; j < anArray.length; j++)
                        System.out.println(anArray[j]);
                   System.exit(0);
              System.exit(0);
              public static Student[] addStudent(Student [] anArray)
                   String sID = JOptionPane.showInputDialog("Enter student's ID: ");
                   String sName = JOptionPane.showInputDialog("Enter student's name: ");
                   String sHoursStr = JOptionPane.showInputDialog("Enter student's hours: ");
                   int sHours = Integer.parseInt(sHoursStr);
                   Student aStudent = new Student(sID, sName, sHours);
                   for(int i = 0; i < anArray.length; i++)
                        if(anArray.getID() == "")
                             anArray[i] = aStudent;
                             System.out.println(anArray[i]);
                             break;
                   return(anArray);
              public static void addHours(Student [] anArray)
                   int totalHours = 0;
                   for(int i = 0; i < anArray.length; i++)
                        totalHours += anArray[i].getHours();
                   JOptionPane.showMessageDialog(null, "Total hours are: " + totalHours);
              public static void findStudent(Student [] anArray)
                   String requestedID = JOptionPane.showInputDialog("Enter ID of student: ");
                   boolean foundIt = false;
                   for(int i = 0; i < anArray.length; i++)
                        if(anArray[i].getID().equals(requestedID))
                             JOptionPane.showMessageDialog(null, anArray[i]);
                             foundIt = true;
                             break;
                   if(!foundIt)
                        JOptionPane.showMessageDialog(null, "Student not found");
    Could someone help me out please?

    import javax.swing.*;
    import java.util.*;
    public class StudentApp
         public static void main(String [] args) throws NullPointerException
              //declare variables and initialize
              String sID, sName, sHoursStr;
              int choice = 0, sHours, i;
              Student aStudent = Null;
              Vector sVector = new Vector();
              //add objects to Vector
              Vector studentVector = new Vector();
              studentVector = addStudent(studentVector);
              sVector.add(aStudent);
              //get objects from a vector and print
              for(i = 0; i < sVector.size(); i++)
                        aStudent = (String) sVector.get(i);
                        System.out.println(aStudent);
                   //copy vector contents into an Array
                   String [] anArray = new String[sVector.size()];
                   sVector.copyInto(anArray);
                   for(j = 0; j < anArray.length; j++)
                        System.out.println(anArray[j]);
                   for(i = 0; i < studentArray.length; i++)
                             studentArray[i] = new Student(); // load the array with empty data
                             while(choice != 4) // keep repeating the menu until 4 is selected
                                  String instructions = "Enter\n"
                                                      + "      1 to add a Student\n"
                                                 + "      2 to delete a Student given the ID\n"
                                                 + "      3 to sum and display the semester hours for all the current Students\n"
                                                 + "      4 to quit";
                                  String choiceStr = JOptionPane.showInputDialog(instructions);
                                  choice = Integer.parseInt(choiceStr);
                                  switch(choice)
                                       case 1:
                                            studentArray = addStudent(studentArray); // call method, send array
                                            break;
                                       case 2:
                                            deleteStudent(studentArray); // call method, send array
                                            break;
                                       case 3:
                                            addHours(studentArray); // call method, send array
                                            break;
                                  } // end switch
                                  System.exit(0);
                             } // end while
              System.exit(0);
    public static Vector addStudent(Vector sVector)
              public static Vector addStudent(Vector sVector)
                   sVector.remove(aStudent);
                   aStudent = (Student) sVector.get(i);
                   sID = aStudent.getID();
                   aStudent = (Student) sVector.get(i);
                   sHours = aStudent.getHours();
                   Vector studentVector = new Vector();
                   studentVector = addStudent(studentVector);
                   sVector.add(aStudent);
                        String sID = JOptionPane.showInputDialog("Enter student's ID: ");
                        String sName = JOptionPane.showInputDialog("Enter student's name: ");
                        String sHoursStr = JOptionPane.showInputDialog("Enter student's hours: ");
                        int sHours = Integer.parseInt(sHoursStr);
                        Student aStudent = new Student(sID, sName, sHours);
                        for(int i = 0; i < anArray.length; i++)
                             if(anArray.getID() == "")
                                  anArray[i] = aStudent;
                                  System.out.println(anArray[i]);
                                  break;
                        return(anArray);
                   System.exit(0);
              public static void deleteStudent(Student [] anArray)
                   String requestedID = JOptionPane.showInputDialog("Enter ID of student that you would like to delete: ");
                   sVector.remove(aStudent);
                   aStudent = (Student) sVector.get(i);
    sID = aStudent.getID();
                   sVector.remove(aStudent);
                   if(!foundIt)
                        JOptionPane.showMessageDialog(null, "Student not found");
              public static void addHours(Student [] anArray)
                   for(i = 0; i < sVector.get; i++)
                        aStudent = (Student) sVector.get(i);
                        sHours = aStudent.getHours();
                        totalHours += sHours; // add up hours
                        JOptionPane.showMessageDialog(null, "Total hours are: " + totalHours);
    Here is my program.. can someone please fix it?

  • Plz send extended wht

    plz tell extended wht configration
    Urgent,
    mee krishna

    Hi,
    WHT has 2 types – a. Accrual basis  b. Payment Basis
    Path: IMG – FA-Fin GS – WHT-Extended WHT
    1.     Basic Settings
    a.     Check WHT countries: Check ur country
    b.     Calculation
    i.     Withholding tax type – Define WHT type for invoice posting: Give ur country, tax type, Base Amt – Select Gross amount à Save
    ii.     WHT Type – Define WHT for payment posting – Similar to 1bi
    iii.     WHT Code  - Country, WHT type, Base Amoutn: 100%, Post Indicator: 1: Std posting, Calculate: WHT Rate: Give ur tax rate.  Similarly do for payment posting
    c.     Define formula for calculating WHT-Give basic details and enter other details by double clicking ‘Formula for calculating WHT’.  Do for both Accrual and payment
    d.     Company code – Assign WHT to cocode – Do for both payment and accrual
    e.     Activate Extended WHT
    2.     Posting: Accoutns for WHT – Define accouts for WHT – Give chart of acct – Select WHT code and Type.  Give the type and code of both accrual n opayment
    3.     IMG-Logistics General – Tax on Goods movement – India – basic settings – Maintain Cocd settings – Give first month and save
    4.     Attach the WHT to Vendor Master (FK02 – change; FKO1 –Create) – Select WHT; Tax type: Either payment/accrual; Select Liable and save
    5.     Try posting entry thru F-43 and enter the WHT. Document àSimulate
    Pls. assign points, if useful</b>
    Regards,
    Sridevi

  • Error Prone Code.  Need Help.

    Last attempt to fix this code. I have included everything but the console code, which isn't needed here.
    THIS IS ALL THE CODE IS SUPPOSED TO DO: Using a console, an Employee enters their name, then enters the numbers of hours they worked, then enters their hourly pay rate. Java then figures up the pay and then prints it out like this: (John Doe, 8.00, 40, 320 are just examples to show what completion would be like).
    Your Name is: John Doe
    Hourly Pay Rate: 8.00
    Hours Worked: 40
    Total Pay: 320.00
    package Employee;
    * <p>Title: Employee</p>
    * <p>Description: Application allows an employee to enter a name, wage rate, hours worked and compute total pay.</p>
    * @version 1.0
    public class Employee() {
           // field variables
      private String name;
      private double hours;
      private double payRate;
      private double Total;
      public Employee()  // empty constructor
           // full constructor.  'Sets' do not return anything, thus void.
    public Employee (String n, double h, double p, double t)
    name = n;
    hours = h;
    payRate = p;
    Total = t;
    }      // end full constructor
           // 'Sets' do not return anything, thus void.
    public void setName (String n)
      name = n;
    public void setHours (double h)
      hours = h;
    public void setpayRate (double p)
      payRate = p;
    public void setTotal(double t)
      Total = t;
           // get all of the field variables
    public String getName()
      return name;
    public double getHours()
      return hours;
    public double getpayRate()
      return payRate;
          // public method to calculate pay
    public double getTotal()
      return Total;
    public double Hours()
      return hours;
    public double payRate()
      return payRate;
    if (payRate >0)
      return
    Total = hours * payRate;
    else
      return 0;
    package Employee;
    * <p>Title: Employee</p>
    * <p>Description: Application allows an employee to enter a name, wage rate, hours worked and compute total pay.</p>
    * @version 1.0
    public class EmployeeDriver {
      public class Console {
      public static void main(String[] args)
        Employee myEmployee = new Employee();
        String eN = Console.readString ("Enter Your Name");
        myEmployee.setName(eN);
        double payRate = Console.readdouble ("Enter Your Rate-of-Pay");
        myEmployee.setpayRate(payRate);
        double Hours = Console.readDouble ("Hours Worked");
        myEmployee.setHours(Hours);
        totalPayThisWeek = payRate * Hours;
             // Output the results.
        System.out.println("Your name is: " + myEmployee.getName());
        System.out.println ("Hourly Pay Rate: " + myEmployee.payRate());
        System.out.println ("Hours Worked: " + myEmployee.getHours());
        System.out.println (" ");   // Print a blank line
        System.out.println("Total Pay: " + myEmployee.totalPayThisWeek());
         System.out.println (" ");   // Print a blank line
        System.out.println("Please hit Enter to continue");
    }

    HI: I found the problems in the Employee.java class. In the EmployeeDriver.java class, the errors are:
    1. Malformed expression at line 15.
    2. Illegal start of expression at line 18.
    When I click on the error messages the lines public static void main ((String argv[])
      { highlight for the "malformed expression" error, and "illegal start" for the public Console = new Console(); line. I tried public Console, private Console, Employee Console and just plain Console, the same error message remained.
    Here's the entire EmployeeDriver code: package Employee;
    * <p>Title: Employee</p>
    * <p>Description: Application allows an employee to enter a name, wage rate, hours worked and compute total pay.</p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: </p>
    * @author John Doe
    * @version 1.0
    public class EmployeeDriver {
    public class Console {
      public static void main(String argv[])
        public Console = new Console();
        Employee myEmployee = new Employee();
        String eN = Console.readString ("Enter Your Name");
        myEmployee.setName(eN);
        double payRate = Console.readDouble ("Enter Your Rate-of-Pay");
        myEmployee.setpayRate(payRate);
        double Hours = Console.readDouble ("Hours Worked");
        myEmployee.setHours(Hours);
             // Output the results.
        System.out.println("Your name is: " + myEmployee.getName());
        System.out.println ("Hourly Pay Rate: " + myEmployee.payRate());
        System.out.println ("Hours Worked: " + myEmployee.getHours());
        System.out.println (" ");   // Print a blank line
        System.out.println("Total Pay: " + myEmployee.totalPayThisWeek());
         System.out.println (" ");   // Print a blank line
        System.out.println("Please hit Enter to continue");
    }

  • How can i stop the started process of downloading ios 8 on my ipad air?plz tell me i dont want to upgrade.

    i have apple ipad air 32gb ,ios 7.0.3 , by mistake i have started the process of update on ios 8 , how can i stop this ? plz tell me.

    The replies don't address the question: "I started getting bombarded with requests to upgrade to Firefox 5.0. This goes on all day, all night...it never stops. Is there a place I can ask you guys to please stop?"
    I have the same problem: I also don't want to upgrade to 5.0 (4.0 messed me up enough and I finally got that straightened out). How do I stop those annoying requests? It should have a "No" option.
    Please email replies to [email protected] Thanks.

  • 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;

  • I create an id. on review option when i enter visa card and security code, it always gives an error msg "Invalid Secruity code". but i use this code for money withdraw from ATM and for shopping also. plz tell the solution ????

    i create an id. on review option when i enter visa card and security code, it always gives an error msg "Invalid Secruity code". but i use this code for money withdraw from ATM and for shopping also. plz tell the solution ????

    The code they are asking for is the last three digits of the number on the back of the card (you don't use this when using an ATM or presenting the card in shops).

  • I was updating my iphone 3g and suddenly  an error occurs (1015) plz tell me how to solve it

    i was updating my iphone 3g through itunes 11 then then suddenly an error occurs no.(1015) plz tell me guys how to solve this?

    Here is what Apple has to say.
    "Error 1015: This error is typically caused by attempts to downgrade the iPhone, iPad, or iPod touch's software. This can occur when you attempt to restore using an older .ipsw file. Downgrading to a previous version is not supported. To resolve this issue, attempt to restore with the latest iPhone, iPad, or iPod touch software available from Apple. This error can also occur when an unauthorized modification of the iOS has occurred and you are now trying to restore to an authorized, default state."

  • I want to download ios8.0.2 but it keep shows me i can't there is an error ..i have iPhone 5s .. would plz tell me what to do?

    i have an iPhone 5s 16gb. latest update is 8.0 ... i tried to download iOS 8.0.2 from boh way , iTunes and my  phone but it keep shows me there is an error and i couldn't download new version .. so would u plz tell me what to do to sort this problem out.
    thank you

    Hi stripers
    You will either a) need to connect to WiFi and complete the download or b) dock your iPad and remove it from the apps list once synced (your iTunes will more then likely want to complete the download first also, which you may be able to cancel in the downloads section).
    Regards
    Damon

Maybe you are looking for