Help:escape hatches in Java

Hello,
Could somebody help me to understand what is the definition of "Escape hatch" in Java? and what are them? I really not clear with them. and google didn't provide any useful info about it.
Thank you very much!

Thank you for your kindly help.
But the problem is I've saw this article before and still not quite understand why they are escape hatches,and what's the benifit of having them,Can you explain it to me with some kinds of examples? and besides those, are there still any other escape hatches exist in Java?
Best wishes,
Yours truely,
CKent

Similar Messages

  • Need help in my assignment, Java programing?

    Need help in my assignment, Java programing?
    It is said that there is only one natural number n such that n-1 is a square and
    n + 1 is a cube, that is, n - 1 = x2 and n + 1 = y3 for some natural numbers x and y. Please implement a program in Java.
    plz help!!
    and this is my code
    but I don't no how to finsh it with the right condition!
    plz heelp!!
    and I don't know if it right or wrong!
    PLZ help me!!
    import javax.swing.JOptionPane;
    public class eiman {
    public static void main( String [] args){
    String a,b;
    double n,x,y,z;
    boolean q= true;
    boolean w= false;
    a=JOptionPane.showInputDialog("Please enter a number for n");
    n=Double.parseDouble(a);
    System.out.println(n);
    x=Math.sqrt(n-1);
    y=Math.cbrt(n+1);
    }

    OK I'll bite.
    I assume that this is some kind of assignment.
    What is the program supposed to do?
    1. Figure out the value of N
    2. Given an N determine if it is the correct value
    I would expect #1, but then again this seem to be a strange programming assignment to me.
    // additions followI see by the simulpostings that it is indeed #1.
    So I will give the tried and true advice at the risk of copyright infringement.
    get out a paper and pencil and think about how you would figure this out by hand.
    The structure of a program will emerge from the mists.
    Now that I think about it that advice must be in public domain by now.
    Edited by: johndjr on Oct 14, 2008 3:31 PM
    added additional info

  • Please help me with these java puzzle ?

    Dear all,
    My friend send me typical java puzzle about java.util.ArrayList
    which is getting messy. Please help me out. It's not a homework.
    Please help me with these java puzzle ?
    Dear all,
    My friend send me typical java puzzle about java.util.ArrayList
    which is getting messy. Please help me out. It's not a homework.
    import java.util.*;
    public class MyInt ______ ________ {
    public static void main(String[] args) {
    ArrayList<MyInt> list = new ArrayList<MyInt>();
    list.add(new MyInt(2));
    list.add(new MyInt(1));
    Collections.sort(list);
    System.out.println(list);
    private int i;
    public MyInt(int i) { this.i = i; }
    public String toString() { return Integer.toString(i); }
    ________ int ___________ {
    MyInt i2 = (MyInt)o;
    return ________;
    }Hints , fill the underlines with below :
    implements
    extends
    Sortable
    Object
    Comparable
    protected
    public
    i = i2.i
    i
    i2.i=i
    compare(MyInt o, MyInt i2)
    compare(Object o, Object i2)
    sort(Object o) sort(MyInt o)
    compareTo(MyInt o)
    compareTo(Object o)

    Dear all,
    My friend send me typical java puzzle aboutNotwithstanding your pathetic protestations typicial
    of all your posts this is NOT a typical java "puzzle"
    but is indeed a typical homework puzzle.
    And it's damn easy if you spent 30 minutes with a
    tutorial.
    DO YOUR OWN HOMEWORK!
    Hey i did it.
    import java.util.*;
    public class MyInt implements Comparable {
    public static void main(String[] args) {
    ArrayList<MyInt> list = new ArrayList<MyInt>();
    list.add(new MyInt(2));
    list.add(new MyInt(1));
    Collections.sort(list);
    System.out.println(list);
    private int i;
    public MyInt(int i) { this.i = i; }
    public String toString() { return Integer.toString(i); }
    public int compareTo(Object o){
    MyInt i2 = (MyInt)o;
    return i;
    }E:\>javac MyInt.java
    Note: MyInt.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    E:\>java MyInt
    [1, 2]

  • I am in the process of doing a Proof Of Concept / Evaluating products that can help us build a Java Application to Convert a PDF document to a Searchable PDF.   I wanted to check is there any simple JAVA API from Adobe to achive this ? Any direction in th

    I am in the process of doing a Proof Of Concept / Evaluating products that can help us build a Java Application to Convert a PDF document to a Searchable PDF. 
    I wanted to check is there any simple JAVA API from Adobe to achive this ? Any direction in this regard is greatly appreciated.@

    You can achieve this using LiveCycle PDF Generator JAVA API. You can find required code here:
    Adobe LiveCycle * Quick Start (SOAP mode): Converting a Microsoft Word document to a PDF document using the Java API
    In parameters:
    //Set createPDF2 parameter values
    String adobePDFSettings = "Standard";
    String securitySettings = "No Security";
    String fileTypeSettings = "Standard OCR";
    "Standard OCR" file type setting will run OCR on input pdf. In the code, instead of doc file provide a pdf file. Resultant pdf will be searchable PDF i.e OCRed PDF.
    Feel feel to ask any further questions.

  • Help to find a Java Text Editor PLEASE

    HELP! I am in need of a program that will compile, execute and have an "autocomplete" sort of thing to help me with learning java. If there are any programs out there sort of like how Visual Basic in Visual Studio 2003-2005. But I need a program specifically for Java because I am learning. Please Reply as soon as possible. Thanks.

    Yes, that's what I meant.
    When I first started programming in Java (I already had exp with C/C++ and command line tools), I was looking for a IDE that had lots of features, two of which were Drag-an-Drop GUI editing and visual debugging. I admit it, I suffer from the Visual Studio way of doing things.
    I downloaded Eclipse and Netbeans and tried both. Eclipse was faster loading but seemed spartan with its features. I also didn't quite understand the way Eclipse handled projects. It was a terminology thing really. Also, I was not familiar with all the various subproject's for eclipse and lacked time to figure it out.
    I then tried Netbeans which loads slower but had everything I wanted in an IDE. Also calling projects 'projects', was easier for me to wrap my head around. That was in version 4 days. Since then, Netbeans has added alot of add on modules and features that are truly impressive for a free IDE. There are third party modules available on the web and adding them to the IDE is usually a 2 or 3 click process... Easy.
    I haven't checked out Eclipse lately but I'm sure they are also doing things to improve their IDE as well. Competition between the two is a good thing, it just benefits the community as a whole.
    (*gets off his soapbox*)
    JJ

  • Help w/ making a Java Pass

    Hey,
    I need some help in making a Java password applet.More specifically, when a button is clicked (e.getsource) getting the text from one text box, (the passwordbox) and printing a statement in another, or on the applet itself, and then taking them to the designated page. If you can understand this, and can help, PLEASE email me at [email protected] I know there is a way to do it in JavaScript, but I'd like to use an applet.
    Thanks!!
    Hoss

    People here don't typically offer a code writing service. That's not intended to be rude or dismissive - it's just the way things are. For all I know you have may have code written and are facing some problem or other. But if you don't post that code and describe that problem, then it can come across as looking for someone else to write your code: something that will generate a warm, but unproductive, response.
    Or maybe you simply have no idea where to start. In that case have a look at the [Graphical User Interfaces|http://java.sun.com/docs/books/tutorial/ui/index.html] section of Sun's Tutorial. The tutorial itself is quite comprehensive so if there are things there concerning basic Java syntax they are very likely explained in earlier sections.

  • How doest jdk docs help as in writing java code?

    hi i wonder how does jdk docs help as in writing java code because if i google a java code the jdk docs always becomes the result of my search but in my experience jdk docs never helps me.
    is there any one know how to use jdk docs? and how to get the code from there.
    im telling about jdk docs from here http://download.oracle.com/javase/1.4.2/docs/api/
    cross posted from http://www.thenewboston.com/forum/viewtopic.php?f=119&t=13778
    Edited by: 871484 on Jul 18, 2011 4:18 PM

    871484 wrote:
    ok can any one give me example how to use jdk docs? for example this code
    Your question still does not make any sense, and you still haven't clarified what you're not understanding.
    However, if you think that just by reading the API docs, with no other training or study, that you will be able to write that code, then you are seriously misunderstanding the purpose of the docs.
    Obviously English is not your native language. You grew up speaking some other language at home and with your friends, and at some point in school or as private study, you started to learn English. You learned about the grammar and the alphabet and pronunciation, sentence structure, word order, etc. Now you have the basics of how the language works, and you know some words. When you want to learn new words to fit into the structure you have learned, you use a dictionary.
    If you didn't study the grammar, sentence structure, etc., and just said, "I want to learn English. I will look at a dicationary," clearly that would not work.
    Right?
    So, since you now understand and agree with the English example, let me state something that I hope is obvious to you by now: The API docs are your dictionary. They are not a substitute for learning the language basics.
    Furthermore, once you know the language basics in English and have your dictionary, you still won't know how to write a resume (which you may know as a CV). You will look at examples and perhaps take a course on resume (CV) writing. Just reading a dictionary won't help you write a resume(CV). Similarly, if you know some Java basics, you can't learn how to write a Swing app just by reading the Javadocs. You'll look at tutorials and examples. Then, once you know the basic structure of a Swing app, you'll look to the javadocs for more details about more kinds of GUI classes--different buttons and windows and panes and panels and layout managers, etc.

  • Need help with long term Java problems

    I've been having problems with Java on my computer for about a year now, and I'm hoping that someone here can help me out.
    Java used to work fine on the computer when I first got it (a Dell laptop) and I hadn't installed anything myself. But then one day it stopped loading Java applets, and hasn't worked since. By this, I mean that I get the little colorful symbol in a box when I try to play Yahoo games, use the http://www.jigzone.com site, go to chat rooms, etc. Java menus on websites like http://www.hartattack.tv used to work still, but lately they've been giving me that symbol too.
    I've tried downloading a newer version of Java, but nothing I do seems to work, and I don't know of anything I did to trigger it not working. I'm hoping there's a simple solution to this, and I'm just dumb.
    Thanks.

    This might be way off, but it's something that's tripped me up in the past:
    If you are using Sun's Java plugin, the first time you go to a site that has a particular Java applet, you may be asked to approve/reject a security request.
    If you have clicked on any other windows while the request is first being loaded (which can take some time, because this is swing based), then the security dialog box does not pop to the top of the window stack, and doesn't add an entry into the task bar.
    It appears that Java just doesn't work, but it's actually waiting for you to click "Yes". You can check this by hitting alt-tab and seeing if the Java coffee cup icon is one of the options.
    - K

  • Help needed in SAP Java- Print option

    Anybody please help quickly,
    Now, I have 2 tables from different queries. I have a print (HTML written) option in my WEB Template
    JAVA PROGRAM:
    function PrintReport(typePaper) {
    document.title ='Report';
    if (typePaper == "0")
    {var CurrentReportName = '&?mp=U&ptot=1&rtot=0&psize=' + escape(typePaper) + '&fsize=' + escape('39') + '&qtitle=' + escape(document.title);};
    if (typePaper == "1")
    {var CurrentReportName = '&?mp=U&ptot=1&rtot=0&psize=' + escape(typePaper) + '&fsize=' + escape('52') + '&qtitle=' + escape(document.title);};
    CurrentReportName += '&ASOFDATE=' + escape(AsOfLabel.innerText);
    var openCMD='<SAP_BW_URL>';
    openCMD += '&DATA_PROVIDER=REPORT_TEST1&TEMPLATE_ID=DPW_PRINT_PAGE&CMD=RELEASE_DATA_PROVIDER';
    openCMD += CurrentReportName;
    openWindow(openCMD,'MainTitleNow',800,600);
    The data provider here is REPORT_TEST1. Now it only prints the corresponding data for the data proviedr 1 i.e., REPORT_TEST1. I have a second table whose data comes from the data provider 2 when i use this HTML to print I want the second table contents from the data provider 2 (REPORT_TEST2)also to be printed simlutaneously.
    Please help.
    THANX A LOT,
    SRINI

    I call the two queries for different web items in the web template. I want a report to print them at once using the print structure in my previous message. If more information is needed please reply

  • Looking for Help with Hyperion to JAVA

    I am looking for help with connecting Hyperion to Java. We are in Maryland but would be willing to work out something for remote consulting. If you have experience with connecting web services, hyperion, and Java and would be interested in about 80 hours of consulting please contact me at:[email protected] x4846

    Hi,
    From your description, you want to achieve the following goal:
    Configure Exchange to filter the attachments if the size is over 10 MB and store it in a public folder, and then forward the email to Salesforce.
    Based on my knowledge, I'm afraid that it can't be achieved. Exchange can filter messages with attachments, but it couldn't store these attachments on public folder automatically. Also, I don't see any transport rule can do it.
    Hope my clarification is helpful.
    Best regards,
    Amy Wang
    TechNet Community Support

  • Need help in creating a java program

    Hi everyone.
    I'd like to say before i start about my problem, that i've only begun learning java and my teacher hasn't explained anything at all. He only showed us by doing it himself and then showing us the final version. I've searched a little on how to program but i get little success in finding a good tutorial.
    I need help creating a program which has been assigned to me due in a few days in which i can't contact my teacher for help.
    I need to write a java program which inputs 3 items. The number of kilometres you drove, the number of litres of gas you used and the price you paid for the gas. Then, the program must calculate the number of litres used per 100km driven, which is litres divided by kilometres times 100, how much it costs to drive 100km, which is the result (a) times the price per litre and the number of miles per American gallon of gas ( one American gallon = 3.785 litres, and one mile = 1.609 km.
    The program has to output my name, the inputs given, the results computed and a message saying "Program Complete".
    To give you what i've done to begin with, from what i understood, is:
    import javax.swing.JOptionPane;
    public class prog1
         public static void main(String args[])
              final double americanGallon = 3.785;
              final double mile = 1.609;
              kilometresDriven,
              gasUsed;
              priceOfLiterGas;
              System.out.println("My Name");
              System.out.println("Number of kilometres driven:");
              kilometresDriven = JOptionPane.showInputDialog ("Kilometres Driven");
              System.out.println("Number of Litres of gas used:");
              gasUsed = JOptionPane.showInputDialog ("Litres of gas used");
              System.out.println("Price of a liter of gas:");
              priceOfLiterGas = JoptionPane.showInputDialog("Price per liter");
    Up to now, that's all i've got. i know i'm wrong, but i'm not sure how to do this. Could someone give me an outline of what this program is suppose to look like?
    Thanks in advance.

    Here's an update on my program. I've worked on certain details and would need your comments whether it contains errors. I'd also want to know if it would work or not because i don't know how to check it on my computer.
    Here's the update:
    import javax.swing.JOptionPane;
    public class Prog1
    public static void main(String args[])
    String name;
    double kmDriven;
    double litresUsed;
    double pricePaidForGas;
    double priceOfALiter;
    name = JOptionPane.showInputDialog("Name");
    input = JOptionPane.showInputDialog("Number of km driven");
    kmDriven = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Number of litres of gas used");
    litresUsed = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Price paid for gas");
    pricePaidForGas = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Price of a litre of gas");
    priceOfALiter = Double.parseDouble (input);
    a = (litresUsed/kmDriven)*100;
    b = ((litresUsed/kmDriven)*100)*priceOfALiter);
    c = (kmDriven/1.609)
    System.out.println("Name:" + name);
    System.out.println("Number of litres used per 100km:" + a);
    System.out.println("Cost of driving 100km" + b);
    System.out.println("Number of miles per American Gallon of Gas:" + c);
    System.out.println("Program Complete");
    System.exit(0);
    Comments please.
    Thanks in advance

  • A CRY OF Help..To All Java Programmer

    Iam desperate please help....I Have to finish this code until tommorrow...i have done some and its running but it doesnt show the right computation...
    Prob:
    Mail order house sells 5 different product..prod1-$2.98, prod2-$4.50, prod3- $9.98, prod4- $4.49 and prod 5- $6.87..Write an application that reads a series of pairs of numbers as follows:
    a)Product number
    b)Quantity sold for one day
    Program should use a switch structure to help determine the retail price for each product.Your program should calculate and display total retail value of all product sold last week. Use a TextField to obtain the product number from the user. Use sentinel -controlled loop to determine when the product should stop looping and display final results.
    Note: I change temporarily the product because I am not familiar with double data types..
    this is the code i have currently done..Please.please.please i need all the help..
    import javax.swing.JOptionPane;
    import java.text.DecimalFormat;
    public class ProbMod {
         public static void main( String args[] )
              int quant,
                   prodnum,
                   Counter,total,input,lahatna,prodquan,
                   gtotal;           
              double      
                        average;
              String
                        num1,
                        num2;
              total = 0;
              Counter = 0;
              gtotal = 1;
              input = 0;
              lahatna = 0;
              prodquan = 0;
                   num1= JOptionPane.showInputDialog( "Enter Product Number, -1 to Quit");
                   prodnum = Integer.parseInt(num1);
              while (prodnum != -1) {
              switch ( prodnum ) {
                   case 1:
                        JOptionPane.showMessageDialog(null, "1 - $2.98");
                        break;
                   case 2:
                        JOptionPane.showMessageDialog(null, "2 - $4.50");
                        break;
                   case 3:
                        JOptionPane.showMessageDialog(null, "3 - $9.98");
                        break;
                   case 4:
                        JOptionPane.showMessageDialog(null, "4 - $4.49");     
                        break;
                   case 5:
                        JOptionPane.showMessageDialog(null, "5 - $6.87");     
                        break;
                   default:
                        JOptionPane.showMessageDialog(null, "Invalid value entered" );     
                        break;
                   }//end switch
                   num2= JOptionPane.showInputDialog( "Enter Quantity, -1 to Quit");
                   quant = Integer.parseInt(num2);
                   num1= JOptionPane.showInputDialog( "Enter Product Number, -1 to Quit");
                   prodnum = Integer.parseInt(num1);
                   if (prodnum == 1) {
                        input = quant * 239;
                   else if (prodnum == 2) {
                        input = quant * 129;     
                   else if (prodnum == 3) {
                        input = quant * 99;
                   else if (prodnum == 4) {
                        input = quant * 350;
                   else if (prodnum == 5) {
                        input = quant * 350;
                   }//endif
                   gtotal = input + 0;
                   Counter = Counter + 1;
              } //end while
              DecimalFormat twoDigits = new DecimalFormat( "0.00");
              if ( Counter != 0) {
              //     average = (double) total/ Counter;
                   lahatna = lahatna + gtotal;
                   JOptionPane.showMessageDialog(null, "Retail Total " + twoDigits.format( lahatna ),
                   "Mail Order House",JOptionPane.INFORMATION_MESSAGE );
              else
              JOptionPane.showMessageDialog( null,"No Product number entered", " ",JOptionPane.INFORMATION_MESSAGE );
              System.exit( 0 );

    Hi.
    I hope the class below meets your needs. Please note that I didn't spend too much time testing it and that I cannot guarantee that it works perfectly. At least it should calculate the correct results for the input values.
    public class ProbMod {
        public ProbMod() {
        public static void main(String[] args) {
            int productNumber = 0;
            int soldAmount = 0;
            double price = 0.0;
            int counter = 0;
            double total = 0.0;
            do {
                try {
                    productNumber = Integer.parseInt(JOptionPane.showInputDialog("Enter product number (-1 to quit)"));
                    switch( productNumber ) {
                        case -1:
                            break;
                        case 1:
                            price = 2.98;
                            break;
                        case 2:
                            price = 4.5;
                            break;
                        case 3:
                            price = 9.98;
                            break;
                        case 4:
                            price = 4.49;
                            break;
                        case 5:
                            price = 6.87;
                            break;
                        default:
                            JOptionPane.showMessageDialog(null, "You have entered an invalid product number. Please try again.");
                            throw new Exception("");
                    if( productNumber != -1 ) {
                        soldAmount = Integer.parseInt(JOptionPane.showInputDialog("Enter quantity"));
                        total += (double)soldAmount * price;
                        counter++;
                } catch( NumberFormatException e1 ) {
                    JOptionPane.showMessageDialog(null, "You have entered a non numeric value. Please try again.");
                    productNumber = 0;
                } catch( Exception e2 ) {
                    productNumber = 0;
            } while( productNumber != -1 );
            JOptionPane.showMessageDialog(null, "Retail total (" + String.valueOf(counter) + " product(s)): " + new DecimalFormat("0.00").format(total));
    }Regards,
    Kai

  • Help needed with Sun Java Studio Creator and EJB in a Portlet Project

    Hi
    I have created an web-application with JSF in Sun Java Studio Creator 2. The web application uses a lot of EJB's which acts as the dataProviders. In a typical jsp page i have more that one data providers(the EJB's) getting used. When i run the project everything opens up properly in the browser and the application seems to be fine.
    But when i create a JSP 168 Portlet project and do exactly the same thing for some reason the Apache Pluto(comes as the default Portlet Container with Studio Creator) conks off.
    Then i started going ahead step by step:
    1. First i created a portletpage and added only one dataProvider(EJB) and ran the project...It gets deployed properly in Pluto and the browser comes up and everything shows up fine.
    2. Just to re-confirm i did the same thing with another dataProvider(EJB). So still we have just 1 EJB in the portlet page. As expected it also worked fiine.
    3. Then when I added more that one dataProviders(EJBs) in the porlet page the Apache Pluto conks off(saying that Pluto is not available)
    I tried doing a lot of things but nothing works...Surprisingly the same thing works when u create a JSF web Application project but the same thing does not work when u create a JSR 168 JSF Portlet Project...
    Did anybody face the same problem..Is it a bug in the Studio Creator...Any help would be highly appreciated.

    Hi,
    There are a few discussion threads in the feedbackprograms portal for Creator 2 EA 2. The URL is:
    https://feedbackprograms.sun.com/login.html
    In the EA discussion forum you will find threads which discuss the concerned topic. In specific look for threads titled:
    # Deploying Portlets
    # Taking a JSC Portlet to Tomcat creates a Faces Mapping Error
    # Problem with Pluto when trying to deploy a portlet
    # Request: JSR-168 Portlet Project without JSF
    We kindly request you to post your further queries related to EA in the above mentioned forum.
    Cheers
    Giri

  • Challange for you, help for me! java program

    I am a beginning java student and desparately (again) in help of someone who will check my java program. See below what they want from me, and try to make a program of it that works in all the ways that are asked. Thank you for helping me, i am running out of time.
    Prem Pradeep
    [email protected]
    Catalogue Manager II
    Specification:
    1.     Develop an object to represent to encapsulate an item in a catalogue. Each CatalogueItem has three pieces of information: an alphanumeric catalogue code, a name, and a price (in dollars and cents), that excludes sales tax. The object should also be able to report the price, inclusive of a 15% sales tax, and the taxed component of the price.
    2.     Data input will come from a text file, whose name is passed in as the first command-line argument to the program. This data file may include up to 30 data items (the program will need to be able to support a variable number of actual items in the array without any errors).
    3.     The data lines will be in the format: CatNo:Description:Price Use a StringTokenizer object to separate these data lines into their components.
    4.     A menu should appear, prompting the user for an action:
    a.     Display all goods: this will display a summary (in tabulated form) of all goods currently stored in the catalogue: per item the category, description, price excluding tax, payable tax and price including tax.
    b.     Dispfay cheapest/dearest goods: this will display a summary of all the cheapest and most expensive item(s) in the catalogue. In the case of more than one item being the cheapest (or most expensive), they should all be listed.
    c.     Sort the list: this will use a selection sort algorithm to sort the list in ascending order, using the catalogue number as the key.
    d.     Search the list: this will prompt the user for a catalogue number, and use a binary search to find the data. If the data has not yet been sorted, this menu option should not operate, and instead display a message to the user to sort the data before attempting a search
    5.     Work out a way to be able to support the inc tax/ex tax price accessors, and the tax component accessor, without needing to store any additional information in the object.
    6.     Use modifiers where appropriate to:
    a.     Ensure that data is properly protected;
    b.     Ensure that the accessors and mutators are most visible;
    c.     The accessors and mutators for the catalogue number and description cannot be overridden.
    d.     The constant for the tax rate is publicly accessible, and does not need an instance of the class present in order to be accessible.
    7.     The program should handle all exceptions wherever they may occur (i.e. file 1/0 problems, number formatting issues, etc.) A correct and comprehensive exception handling strategy (leading to a completely robust program) will be necessary and not an incomplete strategy (i.e. handling incorrect data formats, but not critical errors),
    Sample Execution
    C:\> java AssignmentSix mydata.txt
    Loading file data from mydata.txt ...17 item(s) OK
    CATALOGUE MANAGER: MAIN MENU
    ============================
    a) display all goods b) display cheapest/dearest goods
    c) sort the goods list d) search the goods list
    e) quit
    Option: d
    The goods cannot be searched, as the list is not yet sorted.
    CATALOGUE MANAGER: MAIN MENU
    ============================
    a) display all goods b) display cheapest/dearest goods
    c) sort the goods list d) search the goods list
    e) quit
    Option: b
    CHEAPEST GOODS IN CATALOGUE
    Cat      Description      ExTax      Tax      IncTax
    BA023      Headphones      23.00      3.45      26.45
    JW289      Tape Recorder     23.00      3.45      26.45
    MOST EXPENSIVE GOODS IN CATALOGUE
    Cat      Description      ExTax      Tax      IncTax
    ZZ338      Wristwatch      295.00 44.25      339.25
    CATALOGUE MANAGER: MAIN MENU
    ============================
    a) display all goods b) display cheapest/dearest goods
    c) sort the goods list d) search the goods list
    e) quit
    Option: c
    The data is now sorted.
    CATALOGUE MANAGER: MAIN MENU
    ============================
    a) display all goods b) display cheapest/dearest goods
    c) sort the goods list d) search the goods list
    e) quit
    Option: d
    Enter the catalogue number to find: ZJ282
    Cat Description ExTax Tax IncTax
    ZJ282 Pine Table 98.00 14.70 112.70
    CATALOGUE MANAGER: MAIN MENU
    ============================
    a) display all goods b) display cheapest/dearest goods
    c) sort the goods list d) search the goods list
    e) quit
    Option: e
    Here you have the program as far as I could get. Please try to help me make it compact and implement a sorting method.
    Prem.
    By the way: you can get 8 Duke dollars (I have this topic also in the beginnersforum)
    //CatalogueManager.java
    import java.io.*;
    import java.text.DecimalFormat;
    import java.util.StringTokenizer;
    public class CatalogueManager {
    // private static final double TAXABLE_PERCENTAGE = 0.15;
    // Require it to be publicly accessible
    // static means it is class variable, not an object instance variable.
    public static final double TAXABLE_PERCENTAGE = 0.15;
    private String catalogNumber;
    private String description;
    private double price;
    /** Creates a new instance of CatalogueManager */
    public CatalogueManager() {
    catalogNumber = null;
    description = null;
    price = 0;
    public CatalogueManager(String pCatalogNumber, String pDescription, double pPrice) {
    catalogNumber = pCatalogNumber;
    description = pDescription;
    price = pPrice;
    // the mutators must be most visible
    // the final keyword prevents overridden
    public final void setCatalogNumnber(String pCatalogNumber) {
    catalogNumber = pCatalogNumber;
    // the mutators must be most visible
    // the final keyword prevents overridden
    public final String getCatalogNumber() {
    String str = catalogNumber;
    return str;
    // the mutators must be most visible
    // the final keyword prevents overridden
    public final void setDescription(String pDescription) {
    description = pDescription;
    // the accessors must be most visible
    // the final keyword prevents overridden
    public final String getDescription() {
    String str = description;
    return str;
    // If the parameter is not a double type, set the price = 0;
    // the mutators must be most visible
    public boolean setPrice(String pPrice) {
    try {
    price = Double.parseDouble(pPrice);
    return true;
    catch (NumberFormatException nfe) {
    price = 0;
    return false;
    // the accessors must be most visible
    public double getPrice() {
    double rprice = price;
    return formatDouble(rprice);
    double getTaxAmount(){
    double rTaxAmount = price * TAXABLE_PERCENTAGE;
    return formatDouble(rTaxAmount);
    double getIncTaxAmount() {
    double rTaxAmount = price * (1 + TAXABLE_PERCENTAGE);
    return formatDouble(rTaxAmount);
    double formatDouble(double value) {
    DecimalFormat myFormatter = new DecimalFormat("###.##");
    String str1 = myFormatter.format(value);
    return Double.parseDouble(str1);
    public static void main(String[] args) throws IOException {
    final int MAX_INPUT_ALLOW = 30;
    int MAX_CURRENT_INPUT = 0;
    FileReader fr;
    BufferedReader br;
    CatalogueManager[] catalogList = new CatalogueManager[MAX_INPUT_ALLOW];
    String str;
    char chr;
    boolean bolSort = false;
    double cheapest = 0;
    double mostExpensive = 0;
    String header = "Cat\tDescription\tExTax\tTax\tInc Tax";
    String lines = "---\t-----------\t------\t---\t-------";
    if (args.length != 1) {
    System.out.println("The application expects one parameter only.");
    System.exit(0);
    try {
    fr = new FileReader(args[0]);
    br = new BufferedReader(fr);
    int i = 0;
    while ((str = br.readLine()) != null) {
    catalogList[i] = new CatalogueManager();
    StringTokenizer tokenizer = new StringTokenizer(str, ":" );
    catalogList.setCatalogNumnber(tokenizer.nextToken().trim());
    catalogList[i].setDescription(tokenizer.nextToken().trim());
    if (! catalogList[i].setPrice(tokenizer.nextToken())){
    System.out.println("The price column cannot be formatted as dobule type");
    System.out.println("Application will convert the price to 0.00 and continue with the rest of the line");
    System.out.println("Please check line " + i);
    if (catalogList[i].getPrice() < cheapest) {
    cheapest = catalogList[i].getPrice();
    if (catalogList[i].getPrice() > mostExpensive) {
    mostExpensive = catalogList[i].getPrice();
    i++;
    fr.close();
    MAX_CURRENT_INPUT = i;
    catch (FileNotFoundException fnfe) {
    System.out.println("Input file cannot be located, please make sure the file exists!");
    System.exit(0);
    catch (IOException ioe) {
    System.out.println(ioe.getMessage());
    System.out.println("Application cannot read the data from the file!");
    System.exit(0);
    boolean bolLoop = true;
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    do {
    System.out.println("");
    System.out.println("CATALOGUE MANAGER: MAIN MENU");
    System.out.println("============================");
    System.out.println("a) display all goods b) display cheapest/dearest goods");
    System.out.println("c) sort the goods list d) search the good list");
    System.out.println("e) quit");
    System.out.print("Option:");
    try {
    str = stdin.readLine();
    if (str.length() == 1){
    str.toLowerCase();
    chr = str.charAt(0);
    switch (chr){
    case 'a':
    System.out.println(header);
    System.out.println(lines);
    for (int i = 0; i < MAX_CURRENT_INPUT; i++){
    System.out.println(catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    System.out.println("");
    break;
    case 'b':
    System.out.println("");
    System.out.println("CHEAPEST GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    for (int i = 0; i < MAX_CURRENT_INPUT; i++){
    if (catalogList[i].getPrice() == cheapest){
    System.out.println(catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    System.out.println("");
    System.out.println("MOST EXPENSIVE GODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    for (int i = 0; i < MAX_CURRENT_INPUT; i++){
    if (catalogList[i].getPrice() == mostExpensive) {
    System.out.println(catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    System.out.println("");
    break;
    case 'c':
    if (bolSort == true){
    System.out.println("The data has already been sorted");
    else {
    System.out.println("The data is not sorted");
    break;
    case 'd':
    break;
    case 'e':
    bolLoop = false;
    break;
    default:
    System.out.println("Invalid choice, please re-enter");
    break;
    catch (IOException ioe) {
    System.out.println("ERROR:" + ioe.getMessage());
    System.out.println("Application exits now");
    System.exit(0);
    } while (bolLoop);

    One thing you're missing totally is CatalogueItem!! A CatalogueManager manages the CatalogueItem's, and is not an CatalogueItem itself. So at least you have to have this one more class CatalogueItem.
    public class CatalogueItem {
    private String catalogNumber;
    private String description;
    private double price;
    //with all proper getters, setters.
    Then CatalogueManager has a member variable:
    CatalogueItem[] items;
    Get this straight and other things are pretty obvious...

  • PLEASE  HELP ME..ERROR: JAVA CORRUPT ..

    Hello! I bought a disk called the UnInstaller by McAfee. I had some items I wanted removed off of my computer, but really had no idead exactly what I was doing. I told the disk to make the most availible space on my computer. Well, needless to say, I somehow delelted something crucial to the Java program. I have no idea of how to fix this, as I have already tried reinstalling the browser, and it still didn't help. When I try to go to Pogo.com to play the games, since I deleted over 10,000 files, I have been receiving this message that I have pasted below:
    The following error has occurred:
    Java Corrupted or Misinstalled
    Explanation:
    This error occurs when your Java software has been either misinstalled on your browser or if Java software has been corrupted in some way. Some of the symptoms include a large number of "exception errors", applets not showing up (or showing up as a blank or gray frame), and other crash problems.
    How to Fix the Problem:
    The best way to solve the problem is to upgrade to a newer version of the browser you use. This will come with the latest versions of the Java software so you'll be able to run our Classic Games properly. (You should uninstall your current version before you begin the upgrade in order to start with a clean setup.) If you're already using the latest version of your browser and are experiencing this problem, it's still best if you uninstall your browser and then reinstall to begin anew.
    I have done as the error message stated to do in order to correct this, but I am not able to play any online games now because of this stupid mistake I made. If anyone can help me, it would be so helpful and greatly appreciated! Thank you for your time. Have a great day :-)

    Hello! I bought a disk called the UnInstaller by
    McAfee. I had some items I wanted removed off of my
    computer, but really had no idead exactly what I was
    doing. I told the disk to make the most availible
    space on my computer. Well, needless to say, I
    somehow delelted something crucial to the Java
    program. I have no idea of how to fix this, as I have
    already tried reinstalling the browser, and it still
    didn't help. When I try to go to Pogo.com to play the
    games, since I deleted over 10,000 files, I have been
    receiving this message that I have pasted below:
    The following error has occurred:
    Java Corrupted or Misinstalled
    Explanation:
    This error occurs when your Java software has been
    either misinstalled on your browser or if Java
    software has been corrupted in some way. Some of the
    symptoms include a large number of "exception errors",
    applets not showing up (or showing up as a blank or
    gray frame), and other crash problems.
    How to Fix the Problem:
    The best way to solve the problem is to upgrade to a
    newer version of the browser you use. This will come
    with the latest versions of the Java software so
    you'll be able to run our Classic Games properly. (You
    should uninstall your current version before you begin
    the upgrade in order to start with a clean setup.) If
    you're already using the latest version of your
    browser and are experiencing this problem, it's still
    best if you uninstall your browser and then reinstall
    to begin anew.
    I have done as the error message stated to do in order
    to correct this, but I am not able to play any online
    games now because of this stupid mistake I made. If
    anyone can help me, it would be so helpful and greatly
    appreciated! Thank you for your time. Have a great
    day :-)

Maybe you are looking for

  • VGA Display Detected But Has No Signal

    Hello, Here's the issue, I'm working on a 13" MacbookPro 10.8. I plug in mac's "display port > VGA" adapter to display my second screen on projectors for a power point presentation. The Mac flashes the screen like it recognizes the display and when I

  • OIM 9 and Identity Analytics integration : ClassNotFoundException

    Good afternoon, I was trying to configure SoD Invocation Library using this guide: http://docs.oracle.com/cd/E14899_01/doc.9102/e14763/segregation_duties.htm#sthref117 I implemented SoDAnalysisExecutionOper and SoDDataValidationOper, compiled my Jar

  • AWK Firmware Update 1.1 Broke Keyboard.

    3 battery keyboard updated successfully and worked fine for 2 days after the update. Started pushing random characters by itself and keys repeating by itself (impossible to type a 5 letter word without a lot of junk), some symbols not even on the key

  • NTFS and Guest account

    Using NTFS on Win2000 iFS1.1. If the user does not have an account, they get the default guest user. I see in Setup and Admin guide that SMB def has a parameter of AllowGuestIfNotUser. I see no such parameter in the NTFS sever def file. Is there anot

  • New Bridge update-1.0.6.5

    Just received my new bridge update and notice a subtle but effective change to bridge email. The "send" and message options buttons now appear on the side of the message box when replying etc instead of having to scroll down from the top. Great add o