Can't figure out this NullPointerException

Hi I posted yesterday that I was making an infix to postfix converter for school and I thought I had it finished and all good when i compiled a testapp for it and got this:
Exception in thread "main" java.lang.NullPointerException
     at myStack.push(myStack.java:14)
     at inToPost.translate(inToPost.java:14)
     at itpTest.main(itpTest.java:5)Here is the code that is creating this error:
Method Push in myStack:
public void push(String str)
          Node newTop = null;
          newTop.item = str; // Line 14
          newTop.next = top;
          top = newTop;
     }method translate in inToPost
public void translate(){
          String token;
          inFile.open("data.txt");
          while(!inFile.eof()){
               token = inFile.readString();
               token.trim();
               if(token.compareTo("open") > 0){
                    theStack.push("open");  //Line 14
               else if(token.compareTo("close") > 0){
                    gotRightPar(token);
               else if(token.compareTo("plus") > 0 || token.compareTo("minus") > 0){
                    tokenIsOp(token, 1);
                    break;
               else if(token.compareTo("times") > 0){
                    tokenIsOp(token, 2);
               else if(token.compareTo("pow") > 0 || token.compareTo("goob") > 0){
                    tokenIsOp(token, 3);
               else
                    output = output + " " + token;
          inFile.close();
     }Can someone give me some insight on maybe why this is happening.
I read the API on this error but I don't see why I would have a problem.
As always thanks in advance for the help!

You're a total dumb ass:
public void push(String str)
          Node newTop = null;  // newTop is null
          newTop.item = str; // Line 14; it's still null here.
          newTop.next = top;
          top = newTop;
     }Set newTop to point to a non-null Node.
%

Similar Messages

  • Can't figure out where NullPointerException is coming from

    I will attach the code I have below. It is almost entirely done but i am getting a NullPointerException that is driving me nuts, and I can't figure out were it is coming from.
    Help is greatly appreciated.
    First code:
    import java.util.Scanner;
    import java.io.*;
    import java.util.Random;
    import java.util.Collection;
    public class DistributionPlagiarist
         public static void main(String[] args) throws IOException
              Scanner keyboard = new Scanner(System.in);
              int keyLength=0, phraseLength=0, numberOfPhrases=0;
              String inputFileName="", keepReadingFromFile="", theFile="";
              FrequencyLibrary text = new DenseFrequencyLibrary();
              if(args.length != 4)
                   System.out.println("The command line arguments you entered do not match what is needed.  Please try again.");
                   System.exit(0);
              for(int count=0; count<args.length; count++)
                   keyLength = Integer.parseInt(args[0]);
                   phraseLength = Integer.parseInt(args[1]);
                   numberOfPhrases = Integer.parseInt(args[2]);
                   inputFileName = args[3];
              if(keyLength < 0)
                   while(keyLength < 0)
                        System.out.print("The length of the key (" + keyLength + ")" + " you entered is less than zero.\nPlease enter another key length: ");
                        keyLength = keyboard.nextInt();
                        System.out.println();
              if(phraseLength < 0)
                   while(phraseLength < 0)
                        System.out.print("The desired length of the phrase (" + phraseLength + ")" + " you entered is less than zero.\nPlease enter another phrase length: ");
                        keyLength = keyboard.nextInt();
                        System.out.println();
              if(numberOfPhrases <= 0)
                   while(numberOfPhrases <= 0)
                        System.out.print("The desired number of phrases (" + keyLength + ")" + " you entered is not applicable.\nPlease choose another number: ");
                        keyLength = keyboard.nextInt();
                        System.out.println();
              File file=new File(inputFileName);
              boolean exists = file.exists();
              if (exists == false)
                   while(exists == false)
                        System.out.println("The file you are searching for does not exist.  Please place it in this programs directory.");
                        System.out.print("Please re-enter the file name: ");
                        inputFileName = keyboard.nextLine();
                        file=new File(inputFileName);
                        exists = file.exists();
              int count=keyLength, start=0, stop=0;
              FileReader freader = new FileReader(inputFileName);
              BufferedReader inputFile = new BufferedReader(freader);
              while(keepReadingFromFile != null)
                   keepReadingFromFile = inputFile.readLine();
                   if(keepReadingFromFile == null)
                        break;
                   else
                        theFile = theFile + keepReadingFromFile;
              while(count < theFile.length())
                   String name = theFile.substring(start, keyLength+stop);
                   char singleCharacter = theFile.charAt(count);
                   text.add(name, singleCharacter);
                   start++;
                   stop++;
                   count++;
              int countNumberOfPhrases=0;
              while(numberOfPhrases > 0)
                   countNumberOfPhrases++;
                   String phrase = randomphrase(text, phraseLength, keyLength);
                   System.out.println("Phrase " + countNumberOfPhrases + ":\n" + phrase);
                   numberOfPhrases--;
         private static String randomphrase(FrequencyLibrary textLibrary, int phraseLengthToMake, int startLength)
              String startString="";
              char characterToAdd=' ';
              startLength++;
              Random generator = new Random();
              int sizeOfLibrary=textLibrary.size()/2, randomInt = generator.nextInt(sizeOfLibrary+1), value=0;
              Collection<String> stringNames = textLibrary.makeStringCollection();
              for(String stringFromCollection : stringNames)
                   if(randomInt == value)
                        startString = stringFromCollection;
                   value++;
              String thePhrase = new String(startString);
              System.out.println("INITIAL START:" + startString + "TTTT");
              int substringStart=1;
              while(startLength < phraseLengthToMake)
                   characterToAdd = textLibrary.randomUniformChoose(startString);
                   thePhrase = thePhrase + characterToAdd;
                   System.out.println("CHARACTER:" + characterToAdd + "TTTT");
                   System.out.println("PHRASE:" + thePhrase + "TTTT");
                   startString = thePhrase.substring(substringStart, thePhrase.length());
                   boolean answer = textLibrary.contains(startString);
                   System.out.println(answer);
                   System.out.println("NEW STRING:" + startString + "TTTT");
                   startLength++;
                   substringStart++;
              return thePhrase;
    }Second code:
    import java.util.Collection;
    import java.util.HashMap;
    public class DenseFrequencyLibrary implements FrequencyLibrary
         private HashMap<String, MultiSetOfChar> bookTitleAndCharacterAndIntegerHashMap = new HashMap<String, MultiSetOfChar>();
         private MultiSetOfChar keyAndValuePairs = new DenseMultiSetOfChar();
          * Creates a new DenseFrequencyLibrary with all the essential things clear;
         DenseFrequencyLibrary()
              bookTitleAndCharacterAndIntegerHashMap.clear();
          * Input the value from the creation of the DensneMultiSetOfChar into a HashMap.  If the key
          * already exists then the value associated with it is updated by one.
          * @param character a char to be used in forming the HashMap
          * @return characterMap
         private HashMap<String, MultiSetOfChar> inputIntoMap(String name, char character)
              if(!bookTitleAndCharacterAndIntegerHashMap.containsKey(name))
                   keyAndValuePairs = new DenseMultiSetOfChar(character);
              else
                   keyAndValuePairs.add(character);
              this.bookTitleAndCharacterAndIntegerHashMap.put(name, keyAndValuePairs); //input character and value
              return bookTitleAndCharacterAndIntegerHashMap; //return the new HashMap
          * Returns the number of books in the library.
          * @return |b|, ie the number of books in b
        public int size()
             int numberOfBooks=bookTitleAndCharacterAndIntegerHashMap.size();
             return numberOfBooks;
         * Searches the library for an occurrence of a given book
         * @param target the name of a book to be searched for in the library
         * @return true if and only if the argument is already a book title in the library.
        public boolean contains(String target)
             boolean bookIsInLibrary=false;
             if(bookTitleAndCharacterAndIntegerHashMap.containsKey(target))
                  bookIsInLibrary = true;
             return bookIsInLibrary;
         * Returns the MultiSetOfChar that represents the occurrences of the individual characters
         * in the text of the book indicated by the argument.
         * @param target
         * @return MultiSetOfChar
        public MultiSetOfChar getFrequencies(String target)
             MultiSetOfChar frequencyMultiSetOfChar = bookTitleAndCharacterAndIntegerHashMap.get(target);
             return frequencyMultiSetOfChar;
         * Modifies the character occurrences associated with name to include one more occurrence of element.
         * @param name string of the name of the book
         * @param element character to add to the specified book
        public void add(String name, char element)
             bookTitleAndCharacterAndIntegerHashMap = inputIntoMap(name, element);
         * Modifies the character occurrences associated with name to include one less occurrence of element.
         * @param name string of the name of the book
         * @param element character to be removed from the specified book
         * @return true if and only if the book is modified.
        public boolean remove(String name, char element)
             boolean characterWasRemovedFromBook=false;
             //if the target character is in the map then remove it
              if(bookTitleAndCharacterAndIntegerHashMap.containsKey(name))
                   MultiSetOfChar keyAndValuePairs = bookTitleAndCharacterAndIntegerHashMap.get(name);
                   keyAndValuePairs.remove(element);
                   characterWasRemovedFromBook = true; //set answer to true because the HashMap was changed
              else //target does not exist in the HashMap
                   characterWasRemovedFromBook = false; //set answer to false because the HashMap was not changed
             return characterWasRemovedFromBook;
         * Returns a random character, chosen from the same distribution as the characters appear in the book.
         * For example, if 5% of the characters in "Alice in Wonderland" are an 'A', then this method should
         * return an 'A' about 5% of the time.
         * @param name string of the name of the book to search through and remove a character
         * @return true if and only if the argument is already a book title in the library.
         public char randomUniformChoose(String name)
            MultiSetOfChar keyAndValuePairs = bookTitleAndCharacterAndIntegerHashMap.get(name);
            char randomCharacter = keyAndValuePairs.randomUniformChoose();
              return randomCharacter; //return the random character pulled out
         public Collection<String> makeStringCollection()
              Collection<String> stringCollection = bookTitleAndCharacterAndIntegerHashMap.keySet();
              return stringCollection;
    }Third code:
    import java.util.HashMap;
    import java.util.Set;
    import java.util.Collection;
    import java.util.Random;
    * DenseMultiSetOfChar implements MultiSetOfChar.
    * @mathmodel b is a finite multiset
    * @mathdef
    *  |b| is the cardinality of b
    *  ||c,b|| is the number of occurrences of element c in b
    * @author Kyle Hiltner
    public class DenseMultiSetOfChar implements MultiSetOfChar
         private char characterInput=' ';
         private HashMap<Character, Integer> characterMap = new HashMap<Character, Integer>();
          * Create a new DenseMultiSetOfChar with zero argument
         DenseMultiSetOfChar()
              characterMap.clear(); //clear static HashMap
          * Create a new DenseMultiSetOfChar with the passed in value.
          * @param newChar character input to be added to the HashMap
         DenseMultiSetOfChar(char newChar)
              this.characterInput = newChar; //set characterInput to the value passed in
              characterMap = inputIntoMap(this.characterInput); //call private procedure to add characterInput to HashMap
          * Input the value from the creation of the DensneMultiSetOfChar into a HashMap.  If the key
          * already exists then the value associated with it is updated by one.
          * @param character a char to be used in forming the HashMap
          * @return characterMap
         private HashMap<Character, Integer> inputIntoMap(char character)
              //if the character is not in the HashMap then add it with the starting value of 1
              if(!characterMap.containsKey(character))
                   characterMap.put(character, 1); //input character and value
              else //character does exist
                   int value = characterMap.get(character); //get the value for the specified key
                   value++; //increase the value so as to show that another character was added
                   characterMap.put(character, value); //place the character and new value in the HashMap
              return characterMap; //return the new HashMap
          * Returns the number of elements in this multiset (ie its cardinality).
          * Note that since multisets can include duplicates, the cardinality may be
          * larger than the number of distinct elements. Also, the total number of
          * items in the multiset is bounded above by Integer.MAX_VALUE.
          * @return |b|, ie the cardinality of b
         public int getCardinality()
              int totalElementsInMap=0;
              Collection<Integer> integerCollection = characterMap.values(); //create a collection for easy iteration
              //iterate through each value in the HashMap and compute the total number of elements in the HashMap
              for(Integer valueFromCollection : integerCollection)
                   totalElementsInMap = totalElementsInMap + valueFromCollection; //compute new value of total values
              return totalElementsInMap; //return the final total value
          * Returns the number of occurrences of a given element in the multiset. A
          * simple identity relating getElementCount and getCardinality is that the
          * sum of getElementCount for each char is equal to the cardinality of the
          * set.
          * @param target
          *            char to be counted in the multiset
          * @return ||target,b||, ie the number of occurrences of target in b
         public int getElementCount(char target)
              int numberOfGivenCharacters=0; //set initial value
              //if the HashMap contains the target character then numberOfGivenCharacters is set to the value
              if(characterMap.containsKey(target))
                   numberOfGivenCharacters = characterMap.get(target); //set numberOfGivenCharacters to the value assigned to the target character
              return numberOfGivenCharacters; //return the value for the target character
          * Returns a set such that every element in the multiset is in the set (but
          * no duplicates). The cardinality of the returned set must be less than or
          * equal to |b|. The cardinality of the two are equal if and only if b
          * contains no duplicate elements.
          * @return a set of Character, s, such that: <br />
          *         (for all (Character)i in s : (char)i in b) and <br />
          *         (for all (char)i in b : (Character)i in s)
         public Set<Character> getElementSet()
              Set<Character> characterSet = characterMap.keySet(); //create a Set from the keys of characters in the HashMap     
              return characterSet; //return the character Set
          * Adds a single element to the multiset. This operation always increases
          * the cardinality of the multiset by 1, assuming that the maximum capacity
          * of Integer.MAX_VALUE has not been reached.
          * @param item
          *            the char to be added to b
          * @requires |b| < Integer.MAX_VALUE
          * @alters b
          * @ensures b = #b union {item}
         public void add(char item)
              characterMap = inputIntoMap(item); //call the private method to add new character (item) to the HashMap
          * Removes the target, if it is present in the multiset. The method returns
          * true if and only if it changes the multiset.
          * @param target
          *            the char to be removed
          * @alters b
          * @ensures (target not in #b) ==> (b = #b) <br />
          *          (target in #b) ==> (b union {target} = #b)
          * @return target in #b
         public boolean remove(char target)
              boolean answer=false; //set initial value to false
              //if the target character is in the map then remove it
              if(characterMap.containsKey(target))
                   int value = characterMap.get(target); //find the value associated with the target character
                   //if the value is 1 call remove from the HashMap and remove key and value
                   if(value == 1)
                        characterMap.remove(target); //remove key and value from the HashMap
                   else //value is greater than 1
                        value--; //decrease value to show removal
                        characterMap.put(target, value); //replace target character with new value back into the HashMap
                   answer = true; //set answer to true because the HashMap was changed
              else //target does not exist in the HashMap
                   answer = false; //set answer to false because the HashMap was not changed
              return answer; //return answer
          * Returns a char chosen randomly based on the contents of the multiset.
          * This operation does not remove the char from the multiset or change the
          * multiset in any way. In particular, the cardinality of the multiset is
          * the same before and after this method.
          * <p>
          * Characters should be returned with a random distribution equal to the
          * distribution of characters in the multiset. That is, for a character that
          * appears N times in a multiset of cardinality M, the probability of that
          * character being returned is N / M. For example, a multiset that contains
          * only the character 'a', possibly many times, would always result in an
          * 'a' being generated. On the other hand, a multiset with an equal number
          * of 'a' and 'b' elements would return an 'a' approximately half the time
          * and a 'b' the other half.
          * @requires |b| >= 1
          * @return char c with probability p, where: <br />
          *         p = ||c,b|| / |b|
         public char randomUniformChoose()
              char randomCharacter=' ';
              Random generator = new Random();
              int totalElementsInMap=0;
              Collection<Integer> integerCollection = characterMap.values(); //create a collection for easy iteration
              //iterate through each value in the HashMap and compute the total number of elements in the HashMap. 
              //Do this in case a remove call was made
              for(Integer valueFromCollection : integerCollection)
                   totalElementsInMap = totalElementsInMap + valueFromCollection; //compute new value of total values
              int randomInt = generator.nextInt(totalElementsInMap+1), lowerValue=0, upperValue=0;
              Collection<Character> keyCollection = characterMap.keySet();
              //iterate through each value in the HashMap and compute the total number of elements in the HashMap
              for(Character keyFromCollection : keyCollection)
                 upperValue = upperValue + characterMap.get(keyFromCollection);
                 if(randomInt == upperValue)
                      randomCharacter = keyFromCollection;
                 if(randomInt >= lowerValue && randomInt <= upperValue)
                      randomCharacter = keyFromCollection;
                 lowerValue = upperValue + 1;
              return randomCharacter; //return the random character pulled out
    }The Error:
    Exception in thread "main" java.lang.NullPointerException
         at DenseFrequencyLibrary.randomUniformChoose(DenseFrequencyLibrary.java:137)
         at DistributionPlagiarist.randomphrase(DistributionPlagiarist.java:146)
         at DistributionPlagiarist.main(DistributionPlagiarist.java:112)I will attempt to explain what this does in as few words as possible. For a breakdown of the lab go urlhttp://www.cse.ohio-state.edu/~paolo/teaching/494MJ/labs/lab8.shtml{url}. If you don't feel like reading that: THe program reads in some command line arguments. From there it reads from the file provided in the command line and creates "keys" from the specified length. From there I need to create a phrase of the specified length. If i am supposed to create more then one then i do. That is pretty much it. I can't figure out where (really why) the NullPointerException error is coming from.
    Help is appreciated!!

    Post the actual error text (copy and paste, don't "interpret" it) here.
    It should include a stack trace which references a line number of the program -
    unless you suppressed the trace, in which case change your error handling
    so that the trace is produced.
    Identify which program line in your post the error is pointing to so that we can match
    the error with your program, since your post doesn't have line numbers..
    Edited by: ChuckBing on Nov 16, 2007 7:19 PM
    Also - posting large amounts of code (as you did) will reduce the chance of anyone helping

  • Help, I just can't figure out this code or what to do to make it work

    ok, what i'm trying to do is the following: I created a class called Enrollement, in that class I put in an array of 30 objects to hold the places of 30 names that I used Scanner to bring in from a text file. Ok, that part of the code alone works fine. After that, I know want to write a function that will count the number of times each letter (a-z) appears in the first and last names in the class that are held in that array. I have been working on this for a while making changes doing a bunch of stuff but i keep getting errors with the second part that I honestly don't know how to fix or what i'm doing wrong. I am very new to Java. IF/when anyone responds, please dumb down your answers as much as possible so that I can understand what you are saying, I just have no idea what the errors mean or how to make this program work. my code is below:
    import java.util.Scanner;
       import java.io.File;
        class Enrollment{
           public static void main(String [] args)throws Exception{
             Person [] name = new Person [30];
             Scanner sc = new Scanner(new File("names.txt"));
             while (sc.hasNext()){
                String lastName = sc.next();
                String firstName = sc.next();
                sc.nextLine();
                System.out.println("Name: " + firstName + " " + lastName.substring(0,lastName.length()-1));
           public int chararcterCount(char c){
             int count = 0;
             for(int i = 0;i<30;i++){
                Person p = Person ;
    count = count + p.charCount(c);
    return count;
    public static void main(String [] args)throws Exception{
    Enrollment e = new Enrollment();
    e.print();
    System.out.println("Letter a appears " + e.characterCount('a') + times);
    keeps telling me that public static void main.... is already defined and i know that but once i delete that part from program i just keep getting more errors later and i just have no clue how to make this all work

    the program is supposed to count the number of times
    a certain letter appears in the first and last names
    of the class.I was asking about the particular code snippet you posted, not about the program.
    ....p.charCount is supposed to count the
    number of times that character appears, or at least
    that's what i want it to do, Does it do that? Did you test it? You should write a main method that just constructs a Person object and then call its charcount method for vairous characters--one that appears zero times, one time, and multiple times--and see if you get the right results.
    i'm not too sure of the
    rules aorund here and i don't know if this is taboo,
    but would it be possible tot talk to you in real time
    on AOL Instant Messenger or somethingNo, most people here (myself included) will not do that. It denies others the chance to learn from your problem, and prevents others who might help you from participating in the conversation.

  • Can you figure out this setup? Snow Leopard and Windows 7...

    Here's my potential rig:
    - Running a Mac Pro.
    - 2 Hard Drives:
    1) Snow Leopard on first drive
    2) Windows 7 on second drive
    - 2 24" Apple LED Cinema Displays
    So here's my question...is there a way I can have both OS's running at the same time, with Snow Leopard on the left monitor and Windows 7 on the right monitor, all running out from one computer rig (Mac Pro)?
    I've heard of ppl using Synergy to run dual monitors with dual computers and sharing one keyboard and mouse. I want to do the same EXCEPT run it all out of 1 computer.
    Any advice, suggestions, critiques?
    Thanks!

    You'll have to rely on virtualization there. Check out parallels or VMWare Fusion. I think both companies provide evalauation versions. There's also Sun's free VirtualBox that you might want to give a try. A virtual windows installation won't perform as well as a boot camp installation in all situations
    Cheers,
    Jazz

  • Can't figure out this error...

    The assignment is to create a program that uses a class to store information about DVDs and then diplay the information.
    One error is "cannot find symbol, symbol: constructor Dvd(), location: class Dvd, Dvd mydvd = new Dvd();
    The other error is "cannot find symbol, symbol method calculateValue(), location class DvdTest, System.out.println("The value in inventory is $", calculateValue() );
    Here's my code:
    {code// EmployeeInfo class created by Michelle Groves
    // Last edited April12 09
    public class DvdTest
       public static void main(String args [])
    Dvd mydvd = new Dvd();
    Dvd[] prodArray = new Dvd[2]; // creat an array
    prodArray[0] = new Dvd( 231562, 7.49, 2, "Cars" );
    prodArray[1] = new Dvd( 231562, 7.49, 2, "Toy Story" );
    // Displays first element's info
    System.out.println("The stock number is " + prodArray[0].getstockedDvds());
    System.out.println("Priced at " + prodArray[0].getdvdPrice());
    System.out.println("Inventory contains " + prodArray[0].getstockedDvds());
    System.out.println("The title is " + prodArray[0].getdvdName());
    // Displays second element's info
    System.out.println("The stock number is " + prodArray[1].getstockedDvds());
    System.out.println("Priced at " + prodArray[1].getdvdPrice());
    System.out.println("Inventory contains " + prodArray[1].getstockedDvds());
    System.out.println("The title is " + prodArray[1].getdvdName());
    System.out.println("The value in inventory is $", calculateValue() );
    } //end main
    } // end class
    class Dvd
    private int dvdNumber; // DVD Product Number
    private double dvdPrice; // price of DVD
    private double stockedDvds; // number of units in stock
    private String dvdName; // name of DVD
    public Dvd( int dvdNumber, double dvdPrice, double stockedDvds,
    String dvdName ) // constructor for dvd
    dvdNumber = 0;
    dvdPrice = 0.0;
    stockedDvds = 0.0;
    dvdName = "";
    } // end constructor
    // method to set DVD number
    public void setdvdNumber( int dvdNumber )
    dvdNumber = dvdNumber; // store DVD number
    } // end method setdvdNumber
    // method to retrieve DVD number
    public double getdvdNumber()
    return dvdNumber;
    } // end method getdvdNumber
    // method to set DVD price
    public void setdvdPrice( double dvdPrice )
    dvdPrice = dvdPrice;
    } // end method setdvdPrice
    // method to retrieve DVD price
    public double getdvdPrice()
    return dvdPrice;
    } // end method getdvdPrice
    // method to set stocked number of DVDs
    public void setstockedDvds( double stockedDvds )
    stockedDvds = stockedDvds;
    } // end method setstockedDvds
    // method to retrieve stocked number of DVDs
    public double getstockedDvds()
    return stockedDvds;
    } // end method getstockedDvds
    // method to set DVD Name
    public void setdvdName( String dvdName )
    dvdName = dvdName;
    } // end method setdvdName
    // method to retrieve DVD name
    public String getdvdName()
    return dvdName;
    } // end method getstockedDvds
    // method to calculate pay for week
    public double calculateValue()
    return dvdPrice * stockedDvds;
    } // end method total
    } // end class

    Here's my code a little more readable:
    // EmployeeInfo class created by Michelle Groves
    // Last edited April12 09
    public class DvdTest
    public static void main(String args [])
    Dvd mydvd = new Dvd();
    Dvd[] prodArray = new Dvd[2]; // creat an array
    prodArray[0] = new Dvd( 231562, 7.49, 2, "Cars" );
    prodArray[1] = new Dvd( 231562, 7.49, 2, "Toy Story" );
    // Displays first element's info
    System.out.println("The stock number is " + prodArray[0].getstockedDvds());
    System.out.println("Priced at " + prodArray[0].getdvdPrice());
    System.out.println("Inventory contains " + prodArray[0].getstockedDvds());
    System.out.println("The title is " + prodArray[0].getdvdName());
    // Displays second element's info
    System.out.println("The stock number is " + prodArray[1].getstockedDvds());
    System.out.println("Priced at " + prodArray[1].getdvdPrice());
    System.out.println("Inventory contains " + prodArray[1].getstockedDvds());
    System.out.println("The title is " + prodArray[1].getdvdName());
    System.out.println("The value in inventory is $", calculateValue() );
    } //end main
    } // end class
    class Dvd
    private int dvdNumber; // DVD Product Number
    private double dvdPrice; // price of DVD
    private double stockedDvds; // number of units in stock
    private String dvdName; // name of DVD
    public Dvd( int dvdNumber, double dvdPrice, double stockedDvds,
    String dvdName ) // constructor for dvd
    dvdNumber = 0;
    dvdPrice = 0.0;
    stockedDvds = 0.0;
    dvdName = "";
    } // end constructor
    // method to set DVD number
    public void setdvdNumber( int dvdNumber )
    dvdNumber = dvdNumber; // store DVD number
    } // end method setdvdNumber
    // method to retrieve DVD number
    public double getdvdNumber()
    return dvdNumber;
    } // end method getdvdNumber
    // method to set DVD price
    public void setdvdPrice( double dvdPrice )
    dvdPrice = dvdPrice;
    } // end method setdvdPrice
    // method to retrieve DVD price
    public double getdvdPrice()
    return dvdPrice;
    } // end method getdvdPrice
    // method to set stocked number of DVDs
    public void setstockedDvds( double stockedDvds )
    stockedDvds = stockedDvds;
    } // end method setstockedDvds
    // method to retrieve stocked number of DVDs
    public double getstockedDvds()
    return stockedDvds;
    } // end method getstockedDvds
    // method to set DVD Name
    public void setdvdName( String dvdName )
    dvdName = dvdName;
    } // end method setdvdName
    // method to retrieve DVD name
    public String getdvdName()
    return dvdName;
    } // end method getstockedDvds
    // method to calculate pay for week
    public double calculateValue()
    return dvdPrice * stockedDvds;
    } // end method total
    } // end class

  • Can't figure out this screen mode problem! Pic to illustrate!! THANKYOU FOR YOUR HELP

    THIS IS THE TUT IM FOLLOWING.                                                                        
    THIS IS WHAT MINE LOOKS LIKE BEFORE I APPLY THE SCREEN MODE
    THIS IS WHAT IT LOOKS LIKE AFTER I APPLY SCREEN MODE
    What is the problem????? THANKYOU SO MUCH FOR YOUR HELP.

    You need to understand the meaning of the word Screen.
    It has nothing to do with half tones or rasters.
    It refers to additive (light) colour mixing like on your computer screen. So Red + Green = Yellow and so on. Look at your own screen with a strong magnifying glass to see how it works.
    Like Monika says it works best in RGB mode. If you are working in CMYK you must use a rich black (preferably 100% of all 4 colours in this rare case).
    Incidentally, an opacity mask might be a better way to go for buttons and stuff.
    There too you should use 100% of all 4 colours in the mask when working in CMYK.

  • Can't figure out how to use this latest version of iTunes! How do you add/remove apps on your iPhone when it's connected to your mac? Many thanks, Frustrated

    I can't figure out this new itunes.  How do you import apps from macbook pro to iphone 4S?
    Help! Many thanks!

    OK some changes to make it lok like your old itunes
    View > Show Sidebar  this puts the left panel back and you can see your Library, Device and Playlists
    View > Show Status Bar this outs the grey bar back at he bottom with song info displayed
    Click on the black Arrow in Search and Untick Search Entire Library. Search now works as it did before
    Syncing Apps is the same as before
    Select your device and select the Apps Page
    There is a different button by the side of each app with Installed or Removed on it.
    Click on these and they will change to Will Install or Will Remove. Click apply at the bottom

  • My lifetime calls is glitched at 4,924,000,000 and I can not figure out how to reset this PLEASE HELP URGENTLY I don't know how to resolve this

    My IPhones total life time calls is at 4,924,000,00 and I can't figure out if this is a glitch because I know that I have DEFIANTLY not called for that long I don't know if this will be resolved but someone PLEASE HELP

    Glad it helped!
    For what it's worth, I suspect you'd have to restore the phone as new to resolve the issue. If it were mine, I'd probably elect to live with the weirdness rather than go through the fuss of a restore.
    Best of luck.

  • I downloaded a book on iTunes with my MacBook Pro and can't figure out how to open on my computer.  How do I do this?

    I downloaded a book on iTunes with my MacBook Pro and want to read the book on my computer.  Just can't figure out how to do it.  Do I need a program to read books on the MacBook first or is this something I can get in the app store?
    Any help is much appreciated.
    Thanks!

    You need an .epub reader.

  • I have an apple id but ı can not use it for sign in to itunes connect account while publishing my ibook document. Why ı can not login? What can ı do to figure out this problem?

    I have an apple id but ı can not use it for sign in to itunes connect account while publishing my ibook document. Why ı can not login? What can ı do to figure out this problem?

    As note already on the iBA forum [ AppleID for ibooks publishing ], you need two IDs. You can't use your developer ID.
    If you already signed up for books with that ID, you need to talk to Apple to straighten things out.

  • My iphone 5 broke so had to get a sim card and put it in my husbands old iphone 4. i can not figure out how to get my imformation on this his old phone; contacts, apps ect. i have switched my icloud account and apple id on the phone but nothing. HELP!

    My iphone 5 broke so had to get a sim card and put it in my husbands old iphone 4. i can not figure out how to get my imformation on this his old phone; contacts, apps ect. i have switched my icloud account and apple id on the phone but nothing has changed. please HELP!

    You do a restore as new to wipe the iPhone then at the end of restore you will be asked to restore from backup. Choose your iPhone backup.
    Note you cannot restore an IOS newer than the IOS on iPhone, you need to update iPhone first.

  • Can't Figure Out How to do This

    There's something I've been doing on my Treo 650 that I can't seem to figure out any way to do on my new iPhone 3G. Sorry for the somewhat "long story" here, but
    My wife is Chinese, so as we live our lives together, I have been keeping a continuously running "memo" on my Treo, into which I have periodically typed English words and phrases that would be valuable to learn Chinese equivalents for. So, whenever such a word comes up in life, I pop out that memo on my Treo, add a word to it, and put it away.
    Of course I have kept that, and everything else, sync'ed up with my Mac, so I can see those new words and phrases there too.
    To actually learn these new words and phrases, once every few months, I copy those new words into a spreadsheet, figure up translations for them, and study the result as new Chinese-language lessons.
    So, on the iPhone, it appears that I can do almost all of this using "Notes." But there are two things I can't figure out how to do:
    1. Back up (i.e., sync) that memo to my Mac routinely. Yes, I do see that I can Email it to myself periodically, but that's not quite the same as having a document on the iPhone "automatically" backed up on the Mac.
    2. I don't see any way to bring what I already have on my Treo into a "Note" on the iPhone. If I could copy and paste, I could Email that text to myself and then copy&paste it from that Email into the Note, but there's no copy&paste on the iPhone. I do see that there are "Notes" in the Email application, but those are not editable on the iPhone. They are visible on the iPhone, but can't be edited there. Even if they were editable, they still clutter up my inbox, but perhaps I could devise a "smart mailbox" to address that.
    In the first regard, Emailing is marginally acceptable, but I don't have any idea what to do about the second.
    Thanks for any ideas you might have!

    I'm another one of the very grumpy customers regarding the problems synching Outlook calendars with the new 2.0 iPhone.
    I have another twist: I did not ever have multiple calendars in Outlook until the 2.0 update; I had just one. After I updated the iPhone software to 2.0 I have multiple calendars which I did not create. My iPhone has all the events listed, color coded by these various calendars, but when I look at my calendar(s) in Outlook, I can not see all the events at once. So my iPhone is the most complete, and my computer version is fragmented. This is an unacceptable royal pain. I'm relieved to know it's not just me, my iPhone, my Outlook, etc., but I'm definitely one of the many of us who are grumpy with Apple and impatient for their fix.
    My question is: how do I sync my Outlook to my iPhone and delete all these calendars without deleting events? I just want one calendar again: mine, all mine.
    PS I do have recurring events, but way too many to hand change them all; that's ridiculous. Even if I didn't have many of those it's ridiculous that the recurrences should create these problems. It's a pretty basic electronic calendar function.

  • How to remove stocks, weather,clock, notes, reminders, youtube, game center calc, voice memos,calendar, maps, and stocks? As a person who blew 300 bucks I think I should have a choice if I want to remove this crap but can't figure out how.

    How to remove stocks, weather,clock, notes, reminders, youtube, game center calc, voice memos,calendar, maps, and stocks? As a person who blew 300 bucks I think I should have a choice if I want to remove this crap but can't figure out how.
    any help would make me happy. As it stands now from looking on the web it can't be deleted but making sure before i return this ipod touch. I wan't a clean item the way I wan't it and not how they want it. Like I do not need Itunes and App Store on this ipod because I use my computer only to shop, So many things i like out of the ipod and I am sure lots more people also would like a cleaner ipod/phone or what ever.
    from looking at what I never use I see a total of 14 app's I not want taking up space and my screen.
    yup with the 5.0 came another stupid icon i not like. ( Newsstand )

    yes i moved them into a folder, but I not want them at all on my screen. Guess I return this and pick up a
    Zune HD
    less app's on that then ipod touch. thank you for the responce.

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • The updated iPhoto program is cumbersome.  I am trying to create a Christmas card and can't figure out how to get the fold of the card on the left and not on the top of the card.  I had no trouble with this for the past two years.  Can someone help?

    The updated iPhoto program is cumbersome.  I am trying to create a Christmas card and can't figure out how to get the fold of the card on the left and not on the top of the card.  I had no trouble with this for the past two years.  Can someone help?

    Click on the Layout button lower right and choose a Vertical lyout from the dropdown

Maybe you are looking for