Two class help please

alright, the main purpose is to compute how much it will cost if u enter a weight of the bag and the units....i have the math there, but i cant figure out what im doing wrong....any ideas, something isnt right i can see it,
import java.text.DecimalFormat;
import java.util.Scanner;
import javax.swing.*;
public class Coffee {
     public static void main(String[] args) {
          CoffeeBag checker = new CoffeeBag();
          int weight, numUnits;
          String numUnits1 = JOptionPane.showInputDialog(null, "Enter the number of bags: ");
          String weight1 = JOptionPane.showInputDialog(null, "Enter weight of the units in pounds: ");
          weight = Integer.parseInt(weight1);//string to int//
          numUnits = Integer.parseInt(numUnits1);
          checker.setNumberOfUnits(numUnits);
          checker.setUnitWeight(weight);
          DecimalFormat df = new DecimalFormat("0.00");
          Scanner scanner;
          scanner = new Scanner(System.in);
          System.out.println("Number of bags sold: " + numUnits);
          System.out.println("Weight per bag: " + weight);
          System.out.println("Price per pound: $5.99");
          System.out.println("Sales tax: 7.25%");
          System.out.println();
          System.out.println("Total Price: $" + df.format((float)checker.getTotalPrice()));
class CoffeeBag {
private final static double PRICE_PER_LB = 5.99;
private final static double SALES_TAX = 0.0725;
private int unitWeight, numberOfUnits;
double totalPrice=0;
double subtotal=0;
double salesTax;
double pricePerPound;
//contructors//
public CoffeeBag( int weight, int numUnits ) {
String getWeight;
String getNumUnits;
public CoffeeBag() {
int weight; int numUnits;
//methods//
public void setUnitWeight( int weight ) {
unitWeight=weight ;
public void setNumberOfUnits( int units ) {
numberOfUnits=units;
public int getUnitWeight() {
return unitWeight;
public int getNumberOfUnits() {
return numberOfUnits;
public double getPricePerPound() {
return pricePerPound;
public double getSalesTax() {
return salesTax;
public double getSubtotal() {
return subtotal;
public double getTotalPrice() {
return totalPrice;
}

1) You have to tell us exactly what the problem is. People aren't going to guess, or compile and/or run your code to find out.
2) When you post code, please use [code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.

Similar Messages

  • WaterGlass class help please

    * WaterGlass.java
    * Created: Thu Nov 4 11:01:29 2004
    * @author Pyscho
    * @version 1.0
    public class WaterGlass {
    //FIeld/Attribute declarations
    private int amount;
    private int height;
    private int holelevel;
    private int width;
    private String state;
    private String indstate;
    private String dsline;
    public int starsonlevel;
    public WaterGlass() {
    } // WaterGlass constructor
    //constructor declarations
    public WaterGlass(int h, int w, int a, int hl) {
    //method declarations
    public String dotStartLine(int stars) {
    return dsline;
    public int flow() {
    return 1;
    public int getAmount() {
    return amount;
    public int getHeight() {
    return height;
    public int getHoleLevel() {
    return holelevel;
    public int getWidth() {
    return width;
    public void incAmount(int a) {
    amount++;
    public void setAmount(int w) {
    public void setHoleLevel(int hl) {
    holelevel =hl;
    public int starsOnLevel(int l) {
    return starsonlevel;
    public String toString() {
    return state;
    public String toString(int indent) {
    return indstate;
    } // WaterGlass
    * WaterTest.java
    * Created: Mon Jul 26 11:35:53 2004
    * @author Steve
    * @version 1.0
    public class WaterTest{
    public WaterTest (){
    public static void main(String[] args){
    WaterGlass w1 = new WaterGlass();
    WaterGlass w2 = new WaterGlass(7,7,40,3);
    w1.setAmount(15);
    w1.setHoleLevel(3);
    for (int i=0; i<18;i++) {
    w2.incAmount(w1.flow());
    w2.flow();
    System.out.println(w1.toString(0));
    System.out.println(w2.toString(6));
    System.out.println("\n\n\n");
    } // WaterTest
    I'm trying to get WaterTest.java to run off WaterClass.java, when i run it, it's not displaying the waterglasses, it just says null. Anyone have any suggesstions?

    thanks for your help mate, but im still a bit confused as to what to return in that method. this is from the documentation from the WaterGlass class..
    toString
    public String toString(int indent)
    Return a string representing the current, stable state of the glass. The whole glass is indented by a given number of spaces.
    Parameters:
    indent - the amount indentation
    Returns:
    a string representing the glass
    Can someone please give me suggesstions on what goes in the body of the method?

  • Question about inner class - help please

    hi all
    i have a question about the inner class. i need to create some kind of object inside a process class. the reason for the creation of object is because i need to get some values from database and store them in an array:
    name, value, indexNum, flag
    i need to create an array of objects to hold those values and do some process in the process class. the object is only for the process class that contains it. i am not really certain how to create this inner class. i tried it with the following:
    public class process{
    class MyObject{}
    List l = new ArrayList();
    l.add(new MyObject(....));
    or should i create the object as static? what is the benifit of creating this way or static way? thanks for you help.

    for this case, i do need to create a new instance of
    this MyObject each time the process is running with a
    new message - xml. but i will be dealing with the case
    where i will need a static object to hold some
    property values for all the instances. so i suppose i
    will be using static inner class for that case.The two situations are not the same. You know the difference between instance variables and static variables, of course (although you make the usual sloppy error and call them static objects). But the meaning of "static" in the definition of an inner class is this: if you don't declare an inner class static, then an instance of that inner class must belong to an instance of its containing class. If you do declare the inner class static, then an instance of the inner class can exist on its own without any corresponding instance of the containing class. Obviously this has nothing to do with the meaning of "static" with respect to variables.

  • Calling arraylist from another class - help please!!

    Hey, I need some help calling my arraylist from my GUI class, as the arraylist is in the 'AlbumList' class and not in the 'GUI' class i get the error 'cannot find symbol', which is pretty obvious but i cannot figure how to get around this problem. help would be greatly appreciated.
    i have written ***PROBLEM*** next to the bad line of code!
    Thanks!!
    public class Album
        String artist;
        String title;
        String genre;
        public Album(String a, String t, String g)
            artist = a;
         title = t;
            genre = g;
         public String getArtist()
            return artist;
        public String getTitle()
            return title;
         public String getGenre()
            return genre;
    public class AlbumList
        public ArrayList <Album> theAlbums;
        int pointer = -1;
        public AlbumList()
            theAlbums = new ArrayList <Album>();
        public void addAlbum(Album newAlbum)
         theAlbums.add(newAlbum);
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class GUI extends JFrame
        public int max = 5;
        public int numAlbums = 4;
        public int pointer = -1;
        public GUI ()
            super("Recording System");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel main = new JPanel();
            JPanel panel1 = new JPanel();
            panel1.setLayout(new GridLayout(3,2,0,0));
            JPanel panel2 = new JPanel();
            panel2.setLayout(new GridLayout(1,2,20,0));
            final JLabel artistLBL = new JLabel("Artist: ");
            final JLabel titleLBL = new JLabel("Title: ");
            final JLabel genreLBL = new JLabel("Genre: ");
            final JTextField artistFLD = new JTextField(20);
            final JTextField titleFLD = new JTextField(20);
            final JTextField genreFLD = new JTextField(20);
            final JButton nextBTN = new JButton("Next");
            nextBTN.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    pointer++;
                    artistFLD.setText(theAlbums.get(pointer).getArtist());       ***PROBLEM***
                    titleFLD.setText("NEXT");
                    genreFLD.setText("NEXT");
            final JButton prevBTN = new JButton("Prev");
            prevBTN.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    pointer--;
                    artistFLD.setText("PREVIOUS");
                    titleFLD.setText("PREVIOUS");
                    genreFLD.setText("PREVIOUS");
         panel1.add(artistLBL);
            panel1.add(artistFLD);
            panel1.add(titleLBL);
            panel1.add(titleFLD);
            panel1.add(genreLBL);
            panel1.add(genreFLD);
            panel2.add(prevBTN);
            panel2.add(nextBTN);
            main.add(panel1);
            main.add(panel2);
            setVisible(true);
            this.getContentPane().add(main);
            setSize(500, 500);
    -----------------------------------------------------------------------Thanks!!
    Edited by: phreeck on Nov 3, 2007 8:55 PM

    thanks, it dosnt give me a complication error but when i press the button it says out of bounds error, and i think my arraylist may be empty possibly even though i put this data in.. this is my test file which runs it all.
    any ideas? thanks!!
    public class Test
        public static void main(String []args)
            AlbumList a = new AlbumList();
            String aArtist = "IronMaiden";
            String aTitle = "7thSon";
            String aGenre = "HeavyMetal";
            Album newA = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newA);
            aArtist = "LambOfGod";
            aTitle = "Sacrament";
            aGenre = "Metal";
            Album newB = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newB);
            aArtist = "JohnMayer";
            aTitle = "Continuum";
            aGenre = "Guitar";
            Album newC = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newC);
            aArtist = "StillRemains";
            aTitle = "TheSerpent";
            aGenre = "Metal";
            Album newD = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newD);
         GUI tester = new GUI();
    }

  • Can't find textbox class - help please!

    I'm posting this again, in the hope that more people might help. I already know that the error means that the compiler can't find the class Textbox. I need to know why, because I've copied the relevant parts of the code from another app that builds fine. So why won't this build?
    I'm trying to write and build my first J2ME app. My code starts:
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import java.lang.Math;
    public class TestMIDlet
    extends MIDlet
    implements CommandListener
    private Textbox tbMain;
    public void startApp()
    The build fails with numerous errors of which the first is:
    C:\WTK22\apps\TestMIDlet\src\TestMIDlet.java:9: cannot find symbol
    symbol : class Textbox
    location: class TestMIDlet
    private Textbox tbMain;
    with the caret under the 'T' of Textbox
    I don't understand what's wrong with this, as it's in many of the sample apps I've looked at.
    Thanks
    Ed

    Thanks very much!
    I've lost count of the times I've been caught by that case-sensitivity thing in Javascript. I thought it was just the first letter that had to be capitalised. Progress at last!

  • Class Help Please~~~

    How can i access/use the other class's method's variable?
    For example: There are 2 class, Trans and Rece
    In class Rece, there is a method called initialize, in this method I have defined one identifier called ds;
    public void initialize(){
    DataSource ds = stream.getDataSource();
    How can i use this ds in the other class: Trans?
    Regards
    Alpha

    There are a couple of ways. The most basic way (not the best, but the easiest) is...
    1. Put the datasource outside of the initialize so others can see it
    public class Rece
      public DataSource ds;
      public void initialize()
       ds = stream.getDataSource();
    }2. Now make a reference to it in the other class.
    public class Trans
      public DataSource localDs;
      public void initialize()
        Rece r = new Rece();
        localDs = r.ds; // now localDs is a copy of the datastream from Rece
    }

  • Two classes have the same XML type name??? Please, help...

    Hello!
    I have a simple web service class. I generated the ws server-side classes using wsgen.
    I created a jar file from the generated code.
    Then :
    Endpoint endPoint = Endpoint.create(
    new WebServicesUnitImpl()
    String wsFinalName = "http://localhost:9999/akarmi";
    endPoint.publish( wsFinalName );
    The web service started fine.
    Then called wsimport, and the generated classes have been placed into a jar file.
    Then called the code like this:
    WebServicesUnitImplService service = new WebServicesUnitImplService();
    WebServicesUnitImpl unit = service.getWebServicesUnitImplPort();
    unit.serviceXXX();
    but the code doesn't work at all, resulting this error message:
    Two classes have the same XML type name "{http://ws.components.core.ilogique.vii.com/}getMessages". Use @XmlType.name and @XmlType.namespace to assign different names to them.
         this problem is related to the following location:
              at com.vii.ilogique.core.components.ws.GetMessages
              at public com.vii.ilogique.core.components.ws.GetMessages com.vii.ilogique.core.components.ws.ObjectFactory.createGetMessages()
              at com.vii.ilogique.core.components.ws.ObjectFactory
         this problem is related to the following location:
              at com.vii.ilogique.core.components.ws.GetMessages
    I have this error report on all generated class file! How can i fix this?
    What is the main problem? The SE usage? I copied the lates jax-ws jars into endorsed lib resulting the same.
    Any help is appreciate.

    Hello!
    I have a simple web service class. I generated the ws server-side classes using wsgen.
    I created a jar file from the generated code.
    Then :
    Endpoint endPoint = Endpoint.create(
    new WebServicesUnitImpl()
    String wsFinalName = "http://localhost:9999/akarmi";
    endPoint.publish( wsFinalName );
    The web service started fine.
    Then called wsimport, and the generated classes have been placed into a jar file.
    Then called the code like this:
    WebServicesUnitImplService service = new WebServicesUnitImplService();
    WebServicesUnitImpl unit = service.getWebServicesUnitImplPort();
    unit.serviceXXX();
    but the code doesn't work at all, resulting this error message:
    Two classes have the same XML type name "{http://ws.components.core.ilogique.vii.com/}getMessages". Use @XmlType.name and @XmlType.namespace to assign different names to them.
         this problem is related to the following location:
              at com.vii.ilogique.core.components.ws.GetMessages
              at public com.vii.ilogique.core.components.ws.GetMessages com.vii.ilogique.core.components.ws.ObjectFactory.createGetMessages()
              at com.vii.ilogique.core.components.ws.ObjectFactory
         this problem is related to the following location:
              at com.vii.ilogique.core.components.ws.GetMessages
    I have this error report on all generated class file! How can i fix this?
    What is the main problem? The SE usage? I copied the lates jax-ws jars into endorsed lib resulting the same.
    Any help is appreciate.

  • Itunes doesn't list all of my recent podcasts. My show is Black Tribbles and it only shows episodes through March 2013, however we do at least two shows a week and they aren't listed. The feed works because the show update to my computer. Help please.

    Itunes doesn't list all of my recent podcasts. My show is Black Tribbles and it only shows episodes through March 2013, however we do at least two shows a week and they aren't listed. The feed works because the show update to my computer. Help please.

    Your feed is at http://blacktribbles.podomatic.com/rss2.xml
    When subscribed to in iTunes the recent episodes show, but the Store hasn't updated for some time.
    There appears to be an issue with the feed. In the episode 'WRESTLING MARCH MADNESS: Final Bracket & Championship' of 31st March you will find in the 'description' tag the following line:
    4. KURT ANGLE
    At the end of this line is an invisible character which seems to be wrecking the feed - although it works OK when suscribing in iTunes it won't load in a browser (and I also found the feed very slow to load, which won't help matters with the Store)
    This sort of thing usually happens when you paste text in from a word processing application and manage to include one of the invisible control characters. I don't know how easy it will be do do it in Podomatic but you should delete that entire line and retype it to remove this charter.
    You should keep an eye on the time it takes the feed to be accessed - if there is a long enough delay (and it was quite some seconds when I tried) the Store may well timeout and fail to read it. At the moment it's showing a cached version from the last time it was able to read it.

  • Hi - I'm trying to sync iBooks on my Macbook Pro with iBooks running on my iPad. I have some pdf's download from the net I want to share between devices and I can't work out how to sync the two devices. Any help please?

    Hi - I'm trying to sync iBooks on my Macbook Pro with iBooks running on my iPad. I have some pdf's download from the net I want to share between devices and I can't work out how to sync the two devices. Any help please? I'm running Mavericks

    Thanks for your help Brij011 - much appreciated. Apologies as I'm a newbie but I've looked at the info for synching and I appear to have all the switches flicked on my iPad. Does the iPad and iBooks only sync in iCloud for purchases as I appear to be doing something wrong. I could sync ok when books was in iTunes but since migrating to Mavericks I think I'm doing something wrong!!

  • Urgent help please, I made an file with the size 1024x768, then i made two folios, one for retina 2048x1536 and one for non retina 1024x768, i have alot of video content in it, everything works perfect on my retina ipad, but when i open it on ipad 2 an er

    Urgent help please, I made an file with the size 1024x768, then i made two folios, one for retina 2048x1536 and one for non retina 1024x768, i have alot of video content in it, everything works perfect on my retina ipad, but when i open it on ipad 2 an error appears on the pages with video content?

    its in german:
    der Vorgang könnte nicht abgeschlossen werden.
    something like the process coundnt be completed

  • Hi hope somebody can help? i have acrobat 6 pro, worked well for last two years but then just stopped working. Have reinstalled but still will not open, ronning windows 7. Help please!!

    Hi hope somebody can help? i have acrobat 6 pro, worked well for last two years but then just stopped working. Have reinstalled but still will not open, ronning windows 7. Help please!!  Janice

    Hey janicem42177174,
    Adobe no longer supports the installation and use of Acrobat 6 as it is a very old version which is not compatible with Windows 7.
    I would suggest you to please use the latest version of Acrobat i.e. 11.0.10 which is fully compatible with your OS with its enhanced features and functions.
    You might download a free 30-day trial version of Acrobat from here:
    Download Adobe Acrobat free trial | Acrobat XI Professional
    Let me know how it goes
    Regards,
    Anubha

  • I bought two HD movies and I can not get either one of them to play...help please?

    I bought two HD movies and I can not get either one of them to play...help please?

    What have you tried?
    What happened?
    Error message?
    Any info?

  • Every time an email comes in it's preceded by two telephone rings. I don't know what I did to create the problem so I don't know how to resolve it. HELP PLEASE!!!

    Every time an email comes in it's preceded by two telephone rings. I don't know what I did to create the problem so I don't know how to resolve it. HELP PLEASE!!!

    settings >>>>notifications>>>>Mail >>>>allow notifications >>>off  (your choice )
    settings>>>sounds>>>new mail>>>>none  ( will kill rings )

  • Help with loading dynamic classes ..need help please

    i'm trying to design a program where by i can load dynamic classes
    the problem i'm getting is that only one class is loading.
    classes are loaded by their names,and index numbers of public methods from a linklist
    .When the program runs only the first class is ever loaded and only the methods of that class ..
    help please
    //class loader
    import java.lang.reflect.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    public class Test2 extends Thread
         public Class c;
         public Class Ray;
         public Class[] x;
         public static Object object = null;
         public Method[] theMethods;
         public static Method[] method,usemethod;
         public int methodcount;
         public static int MethodCt;     
         public static JList list;
    public Method[] startClass(String SetMethodName)
         try
              c = Class.forName(SetMethodName);
              object = c.newInstance();
              theMethods = c.getDeclaredMethods();
              // number of methods
              //methodcount = theMethods.length;
         catch (Exception e)
              e.printStackTrace();
    // return the array then invoke the particular method later
    return theMethods ;
    public void RunMethod(Method[] SomeMethod, int methodcount)
         try
              SomeMethod[methodcount].invoke( object,null );
         catch (Exception e)
              e.printStackTrace();
    // end class loader
    //main calling program
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing .*;
    import java.lang.reflect.*;
    public class JFMenu extends JFrame
         public static JMenu pluginMenu;
         public static JMenuBar bar;
         public static final Test2 w = new Test2();
    public static Method[] setmethod;
    private static ClassLinkList startRef = null;
    private static ClassLinkList linkRef3 = null;
    private static ClassLinkList startRef2 = null;
    private String ClassName,ShortCut;
    private int MethodNumber;
    private JMenuItem PluginItem;
         JFMenu()
              super (" JFluro ");     
              JMenu fileMenu = new JMenu("File");
              fileMenu.setMnemonic('F');
              JMenuItem exitItem = new JMenuItem("Exit");
              exitItem.setMnemonic('X');
              fileMenu.add(exitItem);
              exitItem.addActionListener
                   new ActionListener()
                        public void actionPerformed(ActionEvent event )
                             System.exit(0);
              JMenu pluginMenu = new JMenu("Plugins");
              pluginMenu.setMnemonic('P');
              startRef = new ClassLinkList ("Hello","Hello ",2,1926,"Painter");
              addToList("Foo","Foo ",0,1930,"Author");
              while (startRef.linkRef5 != null)
                   //pluginMenu.addSeparator();
                   ClassName = startRef.linkRef5.className;
                   ShortCut = startRef.linkRef5.shortcutName;
    MethodNumber = startRef.linkRef5.methodNumber;
    AddMenuItem(pluginMenu,ShortCut,ClassName,MethodNumber);
                   startRef.linkRef5 = startRef.linkRef5.next;
              // create menu bar and add JFMenu window to it
              JMenuBar bar = new JMenuBar();
              setJMenuBar(bar);
              bar.add(fileMenu);
              bar.add(pluginMenu);
              //attributes for JFMenu frame
              setSize(500,200);
              setVisible(true);
         }// end JFMenu constructor
         public void AddMenuItem(JMenu MainMenu, String shortcut,String className, final int methodCount )
              if (MainMenu==null)
                   return;
              //JMenuItem item;
              JMenuItem item = new JMenuItem(shortcut);
              MainMenu.add(item);
              setmethod = w.startClass(className);
              item.addActionListener
                   new ActionListener()
                        public void actionPerformed(ActionEvent event )
                             w.RunMethod(setmethod,methodCount);
              //item.addActionListener(ij);
         public JMenuItem AddMenuItem2(JMenu MainMenu, String shortcut)
              //if (MainMenu==null)
              //     return Main;
              //JMenuItem item;
              JMenuItem item = new JMenuItem(shortcut);
              MainMenu.add(item);
              //setmethod = w.startClass(className);
              //item.addActionListener(this);
                   new ActionListener()
                        public void actionPerformed(ActionEvent event )
                             w.RunMethod(setmethod,methodCount);
              //item.addActionListener(ij);
         return item;
         public void ReloadMenu(JMenuBar Bar, JMenu PluginMenu)
              if (Bar==null)
                   return;
              //     setJMenuBar(Bar);
              Bar.add(PluginMenu);
              //item.addActionListener(ij);
    public static void main (String args[])
              JFMenu menapp = new JFMenu();
    public static void addToList(String clname, String shcutname, int metnumber, int year2,
                                  String description) {
         // Create instance of class ClassLinkList
    ClassLinkList newRef = new ClassLinkList(clname,shcutname,metnumber,year2,
                                       description);
    // Add to linked list;
         startRef = startRef.addRecordToLinkedList(newRef);
    // end main calling program
    class Hello extends Thread
    public int getNum()
    System.out.println("I can be ");
    return 5;
    public void rayshowName()
    System.out.println("anything i want ");
    public void rayshowName3()
    System.out.println("to be ");
    class Foo extends Thread
    public int getNum()
    System.out.println("IMHOFF");
    return 5;
    public void rayshowName()
    System.out.println("raYMOND");
    // FAMOUS PERSONS LINKED LIST EXAMPLE
    // Frans Coenen
    // Saturday 15 January 2000
    // Depaertment of Computer Science, University of Liverpool
    class ClassLinkList {
    /* FIELDS */
    public String className;
    public String shortcutName;
    public int methodNumber;
    public int yearOfDeath;
    public String occupation;
    public ClassLinkList next = null;
    public ClassLinkList linkRef5 = this;
    public ClassLinkList startRef = null;
    /* CONSTRUCTORS */
    /* FamousPerson constructor */
    public ClassLinkList(String classname, String shortcutname, int methodnumber, int year2,
                                  String description) {
         className = classname;
         shortcutName = shortcutname;
         methodNumber = methodnumber;
         yearOfDeath = year2;
         occupation = description;
         next = null;
    /* METHODS */
    /* Output famous person linked list */
    public void outputClassLinkedList()
         //public ClassLinkList outputClassLinkedList() {
         ClassLinkList linkRef = this;
         // Loop through linked list till end outputting each record in turn
    while (linkRef != null)
         //System.out.println(linkRef5);
         System.out.println(linkRef.className + ", " + linkRef.shortcutName +
                   " (" + linkRef.methodNumber + "-" + linkRef.methodNumber +
                   "): " + linkRef.occupation);
         linkRef = linkRef.next;     
    //return linkRef;
    //public String ShowCasname()
    //return String ;     
    /* Add a new record to the linked list */
    public ClassLinkList addRecordToLinkedList(ClassLinkList newRef) {
         ClassLinkList tempRef, linkRef;
         // Test if new person is to be added to start of list if so return
    if (newRef.testRecord(this) ) {
         newRef.next = this;
         return(newRef);
         // Loop through remainder of linked list
         tempRef = this;
         linkRef = this.next;
         while (linkRef != null) {
         if (newRef.testRecord(linkRef)) {
         tempRef.next = newRef;
              newRef.next = linkRef;
              return(this);
         tempRef = linkRef;
         linkRef = linkRef.next;
    // Add to end
    tempRef.next = newRef;
         return(this);
    /* Delete a record from the linked list given the first and last name. Four
    posibilities:
    1) Record to be deleted is at front of list
    2) Record to be deleted is at end of list
    3) Record to be deleted is in middle of list
    4) Record not found. */
    public ClassLinkList deleteRecord(String lName, String fName) {
    ClassLinkList tempRef, linkRef;
    // Record at start of list
    if ((this.className == lName) & (this.shortcutName == fName))
         return(this.next);
         // Loop through linked list to discover if record is in middle of list.
         tempRef = this;
    linkRef = this.next;
    while (linkRef != null) {
         if ((linkRef.className == lName) & (linkRef.shortcutName == fName)) {
    tempRef.next = linkRef.next;
    return(this);
    tempRef = linkRef;
    linkRef = linkRef.next;
    // Record at end of list, or not found
    if ((linkRef.className == lName) & (linkRef.shortcutName == fName))
                        linkRef = null;
         else System.out.println("Record: " + lName + " " + fName + " not found!");
         return(this);
    /* TEST METHODS */
    /* Test whether new record comes before existing record or not. If so return
    true, false otherwise. */
    private boolean testRecord(ClassLinkList existingRef) {
         int testResult = className.compareTo(existingRef.className);
         if (testResult < 0) return(true);
         else {
         if ((testResult == 0) & (shortcutName.compareTo(existingRef.shortcutName) < 0 ))
                             return(true);
         // Return false
         return(false);
         public void addToList(String clname, String shcutname, int metnumber, int year2,
                                  String description)
         // Create instance of class Famous Person
    ClassLinkList newRef = new ClassLinkList(clname,shcutname,metnumber,year2,
                                       description);
    // Add to linked list;
         startRef = startRef.addRecordToLinkedList(newRef);

    I have a similar problem. I am writing a program to read the class names from database and instantiate several classes which extends from ServiceThread (an abstract class extending from Thread).
    rs = pStmt.executeQuery();
    while(rs.next()) {
    String threadclassname = rs.getString("classname").trim();
    try{
    ServiceThread threadinstance = (ServiceThread)Class.forName(threadclassname).newInstance();
    }catch ...
    So far, only the first class is ever instantiated and runs fine. But subsequent classes do not even get pass the "... ... Class.forName(...).newInstance();" line.
    Funny thing is that there are also no exceptions. The JVM just seem to hang there.

  • HT1725 I downloaded two albums yesterday and only half of each of the songs have downloaded when I play them. There is nothing to say it is waiting for the rest to download and I have checked for available downloads...help please!

    I downloaded two albums yesterday and only half of each of the songs have downloaded when I play them. There is nothing to say it is waiting for the rest to download and I have checked for available downloads...help please!

    no, i had to leave so i logged out and when i opened itunes on my mac and went into the downloads tab it only had one paused download listed. i resumed the download for the one movie listed and the other one never showed up. its been about two weeks since i initially bought the two movies so i figured something was wrong.

Maybe you are looking for