Does this code effect performance.

I am doing some code now :) and I did a method like this, however I do not know if it effects performance for the whole application when the method is being called, or weather it is a good coding standard.
The code in question is the following:
public void myMethid(){
   class c{
      public c(String s){
          System.out.println(s);
   c myC = new c("Hello");
}I know this is a stupid example, however would such a think effect performance, or be wrong? ... would it be better to just declare c as an external class?
regards,
sim085

I have seen ppl complaining about cross posts, but what I am going to do here is cross post my answer, which I feel might be helpful in this situation, and considering that it still lies in the grey area:-
"I smell a very interesting discussion stemming out of it, but your question is as open ended as it could be, what kind of web application and what performance. performance is the most misused word I have come across in a lot of design considerations. It is not one parameter you could measure but a combination of different considerations, which would be as follows:-
1) Response time
2) Responsivesness
3) Latency
4) Thoroughput
5) Load
6) Load sensitivity
7) Efficiency
8) capacity
9) scalabilty
You might want to look on the web as to what they mean since I am not going to go into that detail. But these attributes are independent of each other, an application with good latency might be poor in scalability or other way around, so it depends as to whats the nature and requirements of the app you are looking at then deciding which way you would want to go. Its not that simple.
Secondly I would quote Martin Fowler from his book "Patterns of Enterprise Application Architecture":-
"Too often I have seen designs used or rejected because of performance considerations, which turn out to be bogus once somebody actually does some measurements on the real setup used for the application."
So please go back to the requirements and try to figure out what you are actually looking for."

Similar Messages

  • I have just tried to sync my iphone. Error message saying it cannot be synced has popped up quoting error code (-50). I have just removed old iphone backups from itunes but was very careful to not delete the current one. What does this code mean?

    Hi there,
    I have just tried to sync my iphone.
    Worryingly an error message saying it cannot be synced has popped up quoting error code (-50)
    I have just removed old iphone backups from itunes but was very careful to not delete the current one
    What does this code mean?

    http://support.apple.com/kb/TS1583

  • What does " this code must be redeemed in the Australian storefront " mean? And how can I fix it?

    What does " this code must be redeemed in the Australian storefront " mean? And can I fix it?

    All iTunes gifts and gift cards are country-specific, they can only be redeemed and used in their country of issue. Are you in Australia with an Australian billing address on your account ? If you are then try going to the bottom of the Featured tab in the App Store app on your iPad and tap on your account id, tap on 'View Apple ID' on the popup and log into your account, and then select the Country/Region section and select Australia.
    If you are not in Australia then you won't be able to use it.

  • Please explain what does this code does exactly

    Can any one explain me what does the below code does.
    This is the code written in one of the BADI (ME_PO_PRICING_CUST) .This badi will be triggered when a sales order delivery address is changed and while saving it this will be triggered. Over all what i come to know is they re trigerring a new version in this code. Can anyone explain me what exactly they are doing in this.Thanks...
    METHOD IF_EX_ME_PO_PRICING_CUST~PROCESS_KOMK.
      FIELD-SYMBOLS: <EKKO> TYPE ANY,
                     <PROCSTAT> TYPE MEPROCSTATE,
                     <FRGKE> TYPE FRGKE,
                     <YNAST> TYPE TABLE,
                     <WA_YNAST> TYPE NAST.
      IM_EKKO-PROCSTAT = 02.
    *break-point.
      ASSIGN ('(SAPLMEPO)EKKO') TO <EKKO>.
      ASSIGN ('(SAPLMEPO)YNAST[]') TO <YNAST>.
      IF <EKKO> IS ASSIGNED.
        ASSIGN COMPONENT 'PROCSTAT' OF STRUCTURE <EKKO> TO <PROCSTAT>.
        ASSIGN COMPONENT 'FRGKE' OF STRUCTURE <EKKO> TO <FRGKE>.
        IF <FRGKE> = 'R'.
          <PROCSTAT> = '02'.
        ENDIF.
      ENDIF.
      IF <YNAST> IS ASSIGNED.
        IF <FRGKE> = 'R'.
          LOOP AT <YNAST> ASSIGNING <WA_YNAST>.
            <WA_YNAST>-AKTIV = 'X'.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDMETHOD.

    r_htkl must be a range table. check the declaration part of it.
    p_htkl is a parameter on selection screen i hope.
    so, there are four fields on a range table.(range table are similar to your select options)
    1. SIGN ( I or E  - Inclusive or Exculsive)
    2. OPTION(options like EQ = euqal, BT = Between, CP = contains pattern etc)
    3. LOW (value)
    4. HIGH (value)
    so..
    IF NOT p_htkl IS INITIAL. " checks if some thing is being passed to the parameter
    r_htkl-sign='I'. " give the sign a value I i.e it make inclusive sign
    r_htkl-option='EQ'. " EQ to option means you value will be checked for a equal to condition
    r_htkl-low=p_htkl. " the low field in now assigned the same value of the parameter p_hktl
    APPEND r_htkl. " the range table is appended.
    endif.
    so this range table can be used in select statements as :
    select * from abcd into gt where xyz in r_hktl. ==> this will check for a EQ condition with value in r_hktl-low in database or
    in if statements like : if abc in r_hktl. ==> this will check the EQ condition of abc with the r_hktl-low.
    Had it been
    r_htkl-sign='E'.
    then the condition is same but with a NOT.. that means NOT EQ or NOT BT etc.
    as exclusive of the option.
    etc.
    hope this is clear.
    AND PLEASE CLOSE THE OTHER THREAD (duplicate)

  • Simple Question: Why does this code not exit properly?

    This code is pretty simple. All I want to do is load and play a sound file in an application, but this code to load the sound file does not exit properly. I know that some resources must be allocated which I need to deallocate in order to shut down the process, but I don't know what to call to do a proper shut-down. Any help would be appreciated.
    -adam
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class PlaySoundTest extends java.applet.Applet
    public static void main( java.lang.String[ ] aryArgs )
    java.net.URL urlSound = null;
    try
    urlSound = new java.net.URL( "file:/" + aryArgs[ 0 ] );
    catch( java.net.MalformedURLException murle )
    murle.printStackTrace( );
    System.exit( 1 );
    java.applet.AudioClip acSound = java.applet.Applet.newAudioClip( urlSound );

    HI , If u'r still looking for the solution, this code is working on my system -
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class PlaySoundTest extends java.applet.Applet
    public static void main( java.lang.String[ ] aryArgs ){
    java.net.URL urlSound = null;
    try{  //rahul
    try
    urlSound = new java.net.URL( "file:" + aryArgs[ 0 ] );
    catch( java.net.MalformedURLException murle )
    murle.printStackTrace( );
    System.exit( 1 );
    urlSound = new java.net.URL( "file:" + aryArgs[ 0 ] );
    java.applet.AudioClip acSound = java.applet.Applet.newAudioClip( urlSound );
    if(acSound != null){
    acSound.play();
    catch( Exception murle )
    {        //rahul
    murle.printStackTrace( );
    System.exit( 1 );
    }//main
    The only change I made was in the URL part - file: instead of file:/ .
    The other was of course to play the soundclip ...... :- ) I got really confused the first time I played it .

  • Why does this code fail in command line?

    I am using the "ListDemo" from the java swing tutorial. If I compile it on the command line
    javac ListDemo.java
    It compiles fine. Then when I run it, it says:
    C:\Development\Java\Projects\Projects>java ListDemo
    Exception occurred during event dispatching:
    java.lang.NoSuchMethodError
    at ListDemo.createAndShowGUI(ListDemo.java:196)
    at ListDemo.access$400(ListDemo.java:7)
    at ListDemo$1.run(ListDemo.java:217)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Yet when I load up the same file into Netbeans, it compiles and runs fine! Here is the file:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    /* ListDemo.java is a 1.4 application that requires no other files. */
    public class ListDemo extends JPanel
                          implements ListSelectionListener {
        private JList list;
        private DefaultListModel listModel;
        private static final String hireString = "Hire";
        private static final String fireString = "Fire";
        private JButton fireButton;
        private JTextField employeeName;
        public ListDemo() {
            super(new BorderLayout());
            listModel = new DefaultListModel();
            listModel.addElement("Alan Sommerer");
            listModel.addElement("Alison Huml");
            listModel.addElement("Kathy Walrath");
            listModel.addElement("Lisa Friendly");
            listModel.addElement("Mary Campione");
            listModel.addElement("Sharon Zakhour");
            //Create the list and put it in a scroll pane.
            list = new JList(listModel);
            list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            list.setSelectedIndex(0);
            list.addListSelectionListener(this);
            list.setVisibleRowCount(5);
            JScrollPane listScrollPane = new JScrollPane(list);
            JButton hireButton = new JButton(hireString);
            HireListener hireListener = new HireListener(hireButton);
            hireButton.setActionCommand(hireString);
            hireButton.addActionListener(hireListener);
            hireButton.setEnabled(false);
            fireButton = new JButton(fireString);
            fireButton.setActionCommand(fireString);
            fireButton.addActionListener(new FireListener());
            employeeName = new JTextField(10);
            employeeName.addActionListener(hireListener);
            employeeName.getDocument().addDocumentListener(hireListener);
            String name = listModel.getElementAt(
                                  list.getSelectedIndex()).toString();
            //Create a panel that uses BoxLayout.
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new BoxLayout(buttonPane,
                                               BoxLayout.LINE_AXIS));
            buttonPane.add(fireButton);
            buttonPane.add(Box.createHorizontalStrut(5));
            buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
            buttonPane.add(Box.createHorizontalStrut(5));
            buttonPane.add(employeeName);
            buttonPane.add(hireButton);
            buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            add(listScrollPane, BorderLayout.CENTER);
            add(buttonPane, BorderLayout.PAGE_END);
        class FireListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                //This method can be called only if
                //there's a valid selection
                //so go ahead and remove whatever's selected.
                int index = list.getSelectedIndex();
                listModel.remove(index);
                int size = listModel.getSize();
                if (size == 0) { //Nobody's left, disable firing.
                    fireButton.setEnabled(false);
                } else { //Select an index.
                    if (index == listModel.getSize()) {
                        //removed item in last position
                        index--;
                    list.setSelectedIndex(index);
                    list.ensureIndexIsVisible(index);
        //This listener is shared by the text field and the hire button.
        class HireListener implements ActionListener, DocumentListener {
            private boolean alreadyEnabled = false;
            private JButton button;
            public HireListener(JButton button) {
                this.button = button;
            //Required by ActionListener.
            public void actionPerformed(ActionEvent e) {
                String name = employeeName.getText();
                //User didn't type in a unique name...
                if (name.equals("") || alreadyInList(name)) {
                    Toolkit.getDefaultToolkit().beep();
                    employeeName.requestFocusInWindow();
                    employeeName.selectAll();
                    return;
                int index = list.getSelectedIndex(); //get selected index
                if (index == -1) { //no selection, so insert at beginning
                    index = 0;
                } else {           //add after the selected item
                    index++;
                listModel.insertElementAt(employeeName.getText(), index);
                //If we just wanted to add to the end, we'd do this:
                //listModel.addElement(employeeName.getText());
                //Reset the text field.
                employeeName.requestFocusInWindow();
                employeeName.setText("");
                //Select the new item and make it visible.
                list.setSelectedIndex(index);
                list.ensureIndexIsVisible(index);
            //This method tests for string equality. You could certainly
            //get more sophisticated about the algorithm.  For example,
            //you might want to ignore white space and capitalization.
            protected boolean alreadyInList(String name) {
                return listModel.contains(name);
            //Required by DocumentListener.
            public void insertUpdate(DocumentEvent e) {
                enableButton();
            //Required by DocumentListener.
            public void removeUpdate(DocumentEvent e) {
                handleEmptyTextField(e);
            //Required by DocumentListener.
            public void changedUpdate(DocumentEvent e) {
                if (!handleEmptyTextField(e)) {
                    enableButton();
            private void enableButton() {
                if (!alreadyEnabled) {
                    button.setEnabled(true);
            private boolean handleEmptyTextField(DocumentEvent e) {
                if (e.getDocument().getLength() <= 0) {
                    button.setEnabled(false);
                    alreadyEnabled = false;
                    return true;
                return false;
        //This method is required by ListSelectionListener.
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                if (list.getSelectedIndex() == -1) {
                //No selection, disable fire button.
                    fireButton.setEnabled(false);
                } else {
                //Selection, enable the fire button.
                    fireButton.setEnabled(true);
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("ListDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new ListDemo();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();

    You are not running this code under JDK 1.4
    The setDefaultLookAndFeelDecorated method requires JDK 1.4 version.

  • Why does this code not work?

    String answer = new String("");
    in = new BufferedReader(new InputStreamReader( connection.getInputStream ()));
    String test = new String("");
    for (int i = 0 ; i < 1000 ; i++)
    answer = in.readLine();
    if (answer == null)
    System.out.println ("null");
    break;
    else
    test += answer;
    System.out.println ("answer: " + answer);
    System.out.println ("test: " + test);
    Many times, the loop will go through 2 iterations but each time, test is only equal to the first answer. The second, third, fourth etc.time it goes through the loop, it should concatenate the value of answer to the end of the string variable test. So why is it that whenever i run the program that has this code, the loop might lloop many times (let's say 2 time) but the value of test is only the first answer, and not the first answer concatenated with the second answer.

    It worked for me...my code looks like this...i used FileInputStream instead of connection..
    import java.io.*;
    class Forum {
      public static void main(String a[]) throws IOException{
        String answer = new String("");
        BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream("hi.txt")));
        String test = new String("");
        for (int i = 0 ; i < 1000 ; i++)
        answer = in.readLine();
        if (answer == null)
        System.out.println ("null");
        break;
        else
        test += answer;
        System.out.println ("answer: " + answer);
        System.out.println ("test: " + test);
    my hi.txt is like this:
    fasd rea reks krie
    fsdfasd
    asdfasd
    sfasdf
    asdfasd
    The output is
    answer: fasd rea reks krie
    answer: fsdfasd
    answer: asdfasd
    answer: sfasdf
    answer: asdfasd
    null
    test: fasd rea reks kriefsdfasdasdfasdsfasdfasdfasd
    Is this not the way u want???

  • What does this code do

    hi friends, i came across this code, and i am struck at understanding this code,
    usually loop keyword will be followed by itab, but here there is nothing, same with sort.
        SORT.
      LOOP.
        AT NEW MSEG-WERKS.
    some code
        ENDAT.
        AT NEW MSEG-MATNR.
    some code
          NEW-PAGE.
        ENDAT.
        AT DETAIL.
          WRITE:
          / MSEG-LGORT,
            MSEG-BWART,
            MSEG-MBLNR,
            MSEG-ZEILE.
        ENDAT.
        AT END OF MSEG-MATNR.
          SKIP 1.
          WRITE: 'x y z..'
        ENDAT.
        AT END OF MSEG-WERKS.
          SKIP 1.
         WRITE: 'x y z..'
        ENDAT.
      ENDLOOP.
    an some one please explain me this code, little briefly.
    thank you.

    sorry friends, i forgot to tell that the following piece of code was above this code:
    INSERT
    MSEG-WERKS                             "Plant
    MSEG-MATNR                             "Material
    MSEG-MBLNR                             "Material document
    MSEG-ZEILE                             "Material item
    INTO HEADER.
    INSERT
    LIPS-VBELN                             "Delivery
    LIPS-POSNR                             "Delivery item
    MSEG-LGORT                             "Storage location
    MSEG-BWART                             "Movement type
    MSEG-MENGE                             "Quantity
    MSEG-SHKZG                             "Debit/credit
    MSEG-MEINS                                                  "UoM
    INTO DETAIL.

  • What files does this code need?

    I am trying to use this code from Java Examples In A Nutshell.
    It is a short program that involves reading one and writing to another (I think!) The way I understand things is that there has to be two files for the program to be able to run, from_file & to_file . I have attempted to creat two txt files and saved them as these names in the same folder as the app. The code complies as you would expect, when I try to run it I get Usage: FileCopy <source> <destination> and the app never runs. I suspect I have not created the external files properly. If you can see where I have gone wrong let me know, layman's terms please, Dave.

    When running the compiled "FileCopy.class" with java command you must enter the names of files, i.e.;
    java FileCopy "from_file" "to_file"
    in the command line.
    In this case args[0] is "from_file" and args[1] is "to_file."

  • What happens to unused common table expressions ,Does this affect in performance or ?

    If I write a query with one or more common table expressions to which I
    don't actually refer in the query, do they just get pruned off or do
    they get executed regardless? how does it affect in performance
    Prem Shah

    Try below
    seems when the CTE is not refer in the query then statement inside CTE is not executing at all even if it nested CTE, see for your self
    Create table UserInfo
    UserId int primary key,
    UserName varchar(30)
    GO
    Create table UserInfo1
    UserId int primary key,
    UserName varchar(30)
    GO
    insert into UserInfo
    select 1001,'X1' union all
    select 1002,'X2' union all
    select 1009 ,'X9'
    GO
    insert into UserInfo1
    select 1001,'X1' union all
    select 1002,'X2' union all
    select 1009 ,'X9'
    GO
    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
    GO
    Begin tran
    select * from UserInfo1 where UserId between 1001 and 1009
    and UserName = 'XXXX'
    --Commit
    PRINT 'WITH out CTE access in select'
    SET STATISTICS IO ON
    ;WITH CTE1 AS
    (Select * From UserInfo1)
    select * From UserInfo
    PRINT 'WITH CTE access in select'
    ;WITH CTE1 AS
    (Select * From UserInfo1)
    select * From UserInfo a inner join CTE1 b on a.UserId=b.UserId
    Stats IO
        WITH out CTE access in select
        (3 row(s) affected)
        Table 'UserInfo'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
        (1 row(s) affected)
        WITH CTE access in select
        (3 row(s) affected)
        Table 'UserInfo1'. Scan count 0, logical reads 6, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
        Table 'UserInfo'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
        (1 row(s) affected)
    Thanks
    Saravana Kumar C

  • Why does this code always gotoAndStop at the same frame?

    The symbol "alldoor" contains the following six frames in sequential order: "door1","red_door1","door2","red_door2","door3" and "red_door3".
    var doors:Array =["door1", "door2", "door3"];
    var doorSelector:String = doors[newDoors(0, doors.length - 1)]
    function newDoors (min:Number, max:Number):Number
    var  doorColors:Number = Math.round(Math.random() * (min - max) + max);
    return doorColors;
    alldoor.gotoAndStop(doorSelector);
    alldoor.addEventListener(MouseEvent.CLICK,changeColors );
    function changeColors(e:MouseEvent)
        if (e.currentTarget.currentLabel == doorSelector)
            e.currentTarget.gotoAndStop(currentFrame + 1);
         I am attempting to get this code select one of the frames starting with the string "door" at start up. Then, the door should move to the frame
    directly following it on the timeline when clicked. However, as the code is written, the frame always jumps to the second frame in the symbol,regardless of what the current label is. What should I change?

    either:
    1.  those frames aren't loaded when that code executes or
    2.  you don't have those labels on the timeline that contains that code or
    3.  there is other code executing after your goto changing your frame
    use the trace() function to debug and find which is your problem.

  • Repaint() an applet from a swing applet, why does this code not work?

    below are three files that work as planned except for the call to repaint(). This is envoked when a button is hit in one applet and it should repaint another applet. I opened them up in a html file that simply runs both applets. If you could see why the repaint doesn't work I'd love to know. good luck.
    //speech1
    import java.awt.*;
    import java.applet.Applet;
    import java.awt.event.*;
    //java extension packages
    import javax.swing.*;
    public class speechapp1 extends JApplet implements ActionListener{
    // setting up Buttons and Drop down menus
    char a[];
    Choice choicebutton;
    JLabel resultLabel;
    JTextField result;
    JLabel enterLabel;
    JTextField enter;
    JButton pushButton;
    TreeTest PicW;
    // setting up applets G.U.I
    public void init(){
    // Get content pane and set it's layout to FlowLayout
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // initialise buttons and shit
    a = new char[30];
    choicebutton = new Choice();
    enterLabel = new JLabel("Test");
    enter = new JTextField(30);
    resultLabel= new JLabel("speech label");
    result = new JTextField(30);
    result.setEditable(false);
    // Add items to Choice Button
    choicebutton.addItem("abc");
    choicebutton.addItem("def");
    choicebutton.addItem("ghi");
    choicebutton.addItem("jkl");
    pushButton = new JButton("Click to continue");
    // Add new Tree from file TreeTest.java
    PicW = new TreeTest();
    // Add buttons to container.
    container.add(resultLabel);
    container.add(result);
    container.add(enterLabel);
    System.out.println("");
    container.add(choicebutton);
    System.out.println("");
    container.add(pushButton);
    pushButton.addActionListener(this);
    //choicebutton.addActionListener( this );
    // Set the text in result;
    result.setText("Hello");
    //public void paint(Graphics gg){
    // result.setText("Hello");
    public void actionPerformed(ActionEvent event){
    // continue when action performed on pushButton
    String searchKey = event.getActionCommand();
    System.out.println("");
    if (choicebutton.getSelectedItem().equals("abc"))
    PicW.getPicWeight(1);
    if (choicebutton.getSelectedItem().equals("def"))
    PicW.getPicWeight(2);
    if (choicebutton.getSelectedItem().equals("ghi"))
    PicW.getPicWeight(3);
    if (choicebutton.getSelectedItem().equals("jkl"))
    PicW.getPicWeight(4);
    System.out.println("repainting from actionPerformed method()");
    PicW.repaint();
    import java.applet.Applet;
    import java.awt.*;
    import java.util.*;
    public class TreeTest extends Applet{
    Tree BackgroundImageTree;
    Tree PlayerImageTree;
    Image snow,baby;
    int weight;
    public void getPicWeight(int w){
    weight = w;
    System.out.println("the new weight has been set at: "+weight);
    this.repaint();
    public void init()
    // initialising trees for backgound images and player images
    BackgroundImageTree = new Tree();
    PlayerImageTree = new Tree();
    // initialising images and correcting size of images to correctly fit the screen
    snow = getImage(getDocumentBase(),"snow.gif");
    baby = getImage(getDocumentBase(),"baby.gif");
    // inserting images into correct tree structure
    System.out.println("inserting images into tree: ");
    // inserting background images into tree structure
    BackgroundImageTree.insertImage(1,snow);
    // inserting players into tree structure
    PlayerImageTree.insertImage(1,baby);
    public void paint(Graphics g){
    System.out.println("Searching for selected Image");
    if((BackgroundImageTree.inorderTraversal(1)==null)&&(PlayerImageTree.inorderTraversal(1)==null)){
    System.out.println("There is no tree with the selected value in the trees");
    }else{
    g.drawImage(BackgroundImageTree.inorderTraversal(1),1,3,this);
    //g.drawImage(PlayerImageTree.inorderTraversal(1),55,150,this);
    import java.awt.*;
    import java.applet.Applet;
    class TreeNode {
    TreeNode left;
    Image data;
    TreeNode right;
    int value;
    public TreeNode(int weight,Image picture){
    left = right = null;
    value = weight;
    data = picture;
    public void insert(int v, Image newImage){
    if ( v< value){
    if (left ==null)
    left = new TreeNode(v,newImage);
    else
    left.insert(v,newImage);
    else if (v>value){
    if (right ==null)
    right = new TreeNode(v,newImage);
    else
    right.insert(v, newImage);
    public class Tree{
    private TreeNode root;
    public Tree() {
    root = null;
    public void insertImage(int value, Image newImage){
    if (root == null)
    root = new TreeNode(value,newImage);
    else
    root.insert(value,newImage);
    // in order search of tree.
    public Image inorderTraversal(int n)
    return(inorderHelper(root,n));
    private Image inorderHelper(TreeNode node, int n){
    Image temp = null;
    if (node == null)
    return null;
    if (node.value == n ){
    return(node.data);
    temp = inorderHelper(node.left,n);
    if (temp == null){
    temp = inorderHelper(node.right,n);
    return temp;
    }

    I can fix your problems
    1. You get an error here because you can only invoke the superclass's constructor in the subclass's constructor. It looks like that's what you're trying to do, but you're not doing it right. Constructors don't return any value (actually they do, but it's implied, so you don't need the void that you've got in your code)
    2. I'm not sure, but I think your call to show might be wrong. Move the setsize and setvisible calls to outside of the constructor

  • What does this code implies pls eloborate

    Hi,
    i need eloboratation on the below code and functionality
    1) nast table entries and functionlaity how it works etc details
    2) function module called and how data is transfering into the table from it
    3) bold codes specially
    call function 'RV_PRICE_PRINT_REFRESH'
           TABLES
                tkomv = tkomv.
      clear komk.
      clear komp.
      clear <b>nast_anzal.</b>      "Clear aux. variable for number of outputs
    <b>  if nast-objky+10(6) ne space.
        vbco3-vbeln = nast-objky+16(10).</b>
      else.
        <b>vbco3-vbeln = <i>nast-objky</i>.</b>
      endif.
      vbco3-mandt = sy-mandt.
    <b>  vbco3-spras = nast-spras.   what is happenign her how the values from nast coming where it is getting populated intitally?
      vbco3-kunde = nast-parnr.
      vbco3-parvw = nast-parvw.</b>
      call function 'RV_BILLING_PRINT_VIEW'
           EXPORTING
                comwa                        = vbco3
           IMPORTING
                kopf                         = vbdkr
           TABLES
                pos                          = tvbdpr
           EXCEPTIONS
                terms_of_payment_not_in_t052 = 1
                error_message                = 5
                others                       = 4.
      if not sy-subrc is initial.
        if sy-subrc = 1.
          syst-msgty = 'I'.
          perform p_update.
        endif.
      endif.
    form p_update.
    <b>check xscreen = space.
      call function 'NAST_PROTOCOL_UPDATE'
           EXPORTING
                msg_arbgb = syst-msgid
                msg_nr    = syst-msgno
                msg_ty    = syst-msgty
                msg_v1    = syst-msgv1
                msg_v2    = syst-msgv2
                msg_v3    = syst-msgv3
                msg_v4    = syst-msgv4
           EXCEPTIONS
                others    = 1.</b>
    endform.
    regards
    Arora

    Hi,
    Sorry couldn't see your message,
    Anyways, Baiscally OBJEKY is Document number which uniquely identifies an object (for example, an order). The object key is assigned by the system.
    It is an internal Process.
    For e.g: Purhcase Order or Sales Order.
    Once you Enter Message type in NACE transaction corresponding documents with their message types gets into NAST table.
    Suppose you have P.O. No: 00000001 and if you preview P.O. It will refer entry from NAST table internally as OBJKY: 00000001 whcih is your P.O.
    You can directly write into a Program routine NAST-OBJKY, it will automatically picks up the PO no while previewing or Printing it.
    Now in your case Sales Doc.Access Methods: Key Fields: Document Printing
    vbco3 is the table defined in the same program. Double click to check it.
    You are storing corresponding values from NAST to vbco3 table.
    As you get entire row from NAST referring to your Document.
    'RV_BILLING_PRINT_VIEW': Shows Preview of a document.
    Now if it returns an error it will update the log for NAST that if you want to see the print log can be seen.
    Hope this helps.
    Reward if usegful!

  • ADF 10g: What does this code do?

    What is the difference between this and calling createRootApplicationModule() ? I'm looking for some definitive documentation on this.
       FacesContext fc = FacesContext.getCurrentInstance();
                ValueBinding vb = fc.getApplication().createValueBinding("#{data}");
                BindingContext bc = (BindingContext)vb.getValue(fc);
                DCDataControl dc = bc.findDataControl(amName);
                ApplicationModule am = (ApplicationModule)dc.getDataProvider();I understand it (the above code) is no different from picking it from a specific pageDefinition (say where an action binding to a method of that AM is present) or the above -
    both return an AM instance from the data controls within the current FacesContext. But still, any documentation that would relieve this information itch would be much appreciated.
    Also, any thoughts on the 'best practiceness' quotient of doing the above?
    Edited:
    This is posted just to seek clarification - please refer to the whole thread, links provided as references and the developer guide for the recommended approaches.

    posted will grab the one that has been checked out for the page by the binding filter.Here's the thing: this AM, its methods or any of it's constituent VO attributes do NOT have a binding (but could have, since this AM is exposed in the data controls)
    Just note the use of that #{"data"} EL used above (not #{"bindings"} or #{"data.pageDefName"} ).
    In most all cases, you want the same one that has already been checked out - so getting it via the binding context is preferred.Precisely - is there official documentation that confirms that this is a preferred way?
    It is generally pretty rare where you need to createRootApplicationModule,In fact, not at all - except in test code.
    but you might do so in cases where there is not one already checked out for you (for example, if you are interacting with ADF BC from within a servlet).It would be great to have documentation that says it's ok to do so. Otherwise, I strongly think things could be designed better to even avoid doing that.
    Furthermore, it would be even more preferred not to interact with the AM directly in code, but to expose any methods you might want to call via the data control.Method bindings would be 'ideal'. Using the client interface is currently 'ok' (or at least a lesser evil).
    In any new code I wouldn't interact with an AM in UI code - just that there is a whole lot of legacy code which does so. I'm just making sure that the above alternative to createRootApplicationModule is not just equally bad. (i.e. does not require an explicit 'release' call)
    http://blogs.oracle.com/smuenchadf/2009/09/best_practice_example_for_invo.htmlTotally agree with with the above - and yet get hold of an AM instance via its interface the 'right' way in old code that needs it.
    Thanks for the response.

  • Programming project: does this code look clean enough to turn in?

    Hi, i was just wanting to know people's opinion on the format of my classes below, i haven't done much java programming and I just want to make sure that this program is easily understood. I will not be able to respond, because I have to wake up in 3 hours for school. So thanks in advance, I will be reading this tomorrow, to see your suggestions, thank you.
    here is the scholar class, it is the class that i made to create a scholar(student object) that will be applying for a scholarship and the grades are entered in the ScholarTester class.
    I could've done things differently and easier but the professor strictly called for it to be exactly as he stated. I came up with a better, less tedious way, but i couldn't use it. My way was to create a method to randomly generate grades and values to determine the major, but my prof. saw it and made me implement everything in ScholarTester. Also neither of the students will receive the scholarship, that will be determined in project 2 my professor said.
    package project1;
    import java.util.*;
    * @author Kevin
    public class Scholar implements Comparable {
        // private variables
        private String fullName;
        private double gradePointAverage;
        private int essayScore;
        private int creditHours;
        private boolean scienceMajor;
        private double totalScore;
           // constructor for a Scholar object
            public Scholar(String myFullName, double myGradePointAverage, int myEssayScore,
                           int myCreditHours, boolean isScienceMajor){
                    this.fullName = myFullName;
                    this.gradePointAverage = myGradePointAverage;
                    this.essayScore = myEssayScore;
                    this.creditHours = myCreditHours;
                    this.scienceMajor = isScienceMajor;
            // returns a Scholar object's fullname
            public String getFullName(){
                return fullName;
            // returns a Scholar object's gpa
            public double getGradePointAverage(){
                return gradePointAverage;
            // returns a Scholar object's essay score
            public int getEssayScore(){
                return essayScore;
            /// returns a Scholar object's credit hours
            public int getCreditHours(){
                return creditHours;
            // retruns if a Scholar object is a science major or not
            public boolean getScienceMajor(){
                return scienceMajor;
            // sets a Scholar object's full name
            public String setFullName(String lastName, String firstName){
               fullName = lastName + ", " + firstName;
               return fullName;
            // sets a Scholar object's gpa
            public double setGradePointAverage(double a){
                gradePointAverage = a;
                return gradePointAverage;
            // sets a Scholar object's gpa
            public int setEssayScore(int a){
                essayScore = a;
                return essayScore;
            // sets a Scholar object's credit hours
            public int setCreditHours(int a){
                creditHours = a;
                return creditHours;
            // sets a Scholar's major to a science major or not a science major
            public boolean setScienceMajor(boolean a){
                scienceMajor = a;
                return scienceMajor;
            // calculates a Scholar object's score
            public double getScore(){
                totalScore = (gradePointAverage*5) + essayScore;
                if (scienceMajor == true)
                    totalScore += .5;
                if (creditHours >= 60 && creditHours <90)
                    totalScore += .5;
                else if (creditHours >= 90)
                    totalScore += .75;
                return totalScore;
            // compares two scholar objects.
            public int compareTo(Object obj){
                Scholar otherObj = (Scholar)obj;
                double result = getScore() - otherObj.getScore();
                if (result > 0)
                    return 1;
                else if (result < 0)
                    return -1;
                return 0;
            // returns the highest scoring of two Scholar objects
            public static Scholar max(Scholar s1, Scholar s2){
                if (s1.getScore() > s2.getScore())
                    System.out.println(s1.getFullName() + " scored higher than " +
                                       s2.getFullName() + ".\n");
                else
                   System.out.println(s2.getFullName() + " scored higher than " +
                                       s1.getFullName() + ".\n");
                return null;
            // returns the highest of 3 student objects
            public static Scholar max(Scholar s1, Scholar s2, Scholar s3){
                if (s1.getScore() > s2.getScore() && s1.getScore() > s3.getScore())
                    System.out.println(s1.getFullName() + " scored the highest" +
                            " out of all three students.");
                else if (s2.getScore() > s1.getScore() && s2.getScore() > s3.getScore())
                    System.out.println(s2.getFullName() + " scored the highest" +
                            " out of all three students.");
                else if (s3.getScore() > s2.getScore() && s3.getScore() > s1.getScore())
                    System.out.println(s3.getFullName() + " scored the highest" +
                            " out of the three students.");
                return null;
            // toString method for a Scholar object
            public String toString(){
                return  "Student name: " + fullName + " -" + " Grade Point Average: "
                        + gradePointAverage  + ". " + "Essay Score: " + essayScore + "."
                        + " Credit Hours: " + creditHours + ". "  +  " Science major: "
                        + scienceMajor + ".";
    }here's the ScholarTester class:
    package project1;
    import java.util.*;
    * This program creates Scholar objects that are applying for a scholarship
    * @author Kevin
    public class ScholarTester {
    public static void main(String [] args){
    System.out.println("This program was written by Kevin Brown. \n");
    System.out.println("--------Part 1--------\n");
    // attributes for a scholar object named abraham
    double abrahamGpa;
    int abrahamEssayScore;
    int abrahamCreditHours;
    int scienceMajorValueAbraham;
    boolean abrahamIsScienceMajor;
        // random numbers used for each scholar object.
        Random doubleGpa = new Random();
        Random intGpa = new Random();
        Random essayScore = new Random();
        Random creditHours = new Random();
        Random scienceMajor = new Random();
            // randomly creates abraham's statistics
            abrahamGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
            abrahamEssayScore = essayScore.nextInt(6);
            abrahamCreditHours = creditHours.nextInt(121);
            scienceMajorValueAbraham = scienceMajor.nextInt(2);
                if (scienceMajorValueAbraham == 0)
                 abrahamIsScienceMajor = true;
                else
                 abrahamIsScienceMajor = false;
    Scholar abraham = new Scholar("Lincoln, Abraham", abrahamGpa,
                                      abrahamEssayScore, abrahamCreditHours,
                                      abrahamIsScienceMajor);
    System.out.println(abraham);
    double georgeGpa;
    int georgeEssayScore;
    int georgeCreditHours;
    int scienceMajorValueGeorge;
    boolean georgeIsScienceMajor;
        // randomly creates george's statistics
        georgeGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
        georgeEssayScore = essayScore.nextInt(6);
        georgeCreditHours = creditHours.nextInt(131);
        scienceMajorValueGeorge = scienceMajor.nextInt(2);
             if (scienceMajorValueGeorge == 0)
                 georgeIsScienceMajor = true;
             else
                 georgeIsScienceMajor = false;
    // new scholar object is created from the existing attributes
    Scholar george = new Scholar("Bush, George",  georgeGpa, georgeEssayScore,
                                          georgeCreditHours, georgeIsScienceMajor);
    System.out.println(george + "\n");
    System.out.println("--------Part 2--------\n");
    System.out.println(abraham.getFullName() + " scored " + abraham.getScore() + ".");
    System.out.println(george.getFullName() + " scored " + george.getScore() + ".\n");
    System.out.println("--------Part 3--------\n");
    /* comparing george bush and abraham lincoln's scores and printing them out to
             show that the compareTo method is working*/
             System.out.println(abraham.getFullName() + " scored "
                                + abraham.getScore() + ".");
             System.out.println(george.getFullName() + " scored "
                                + george.getScore() + ".\n");
    if(abraham.compareTo(george) == 1)
        System.out.println(abraham.getFullName() + " scored higher than " +
                george.getFullName() + ".\n");
    else
        System.out.println(george.getFullName() + " scored higher than " +
                abraham.getFullName() + ".\n");
    System.out.println("--------Part 4--------\n");
        // prints out scores to show proof that the Scholar.max method is working right.
        System.out.println(abraham.getFullName() + " scored "
                           + abraham.getScore() + ".");
        System.out.println(george.getFullName() + " scored "
                           + george.getScore() + ".\n");
        Scholar.max(abraham, george); // maximum score between abraham and george.
    // variables for a scholar object named thomas.
        double thomasGpa;
        int thomasEssayScore;
        int thomasCreditHours;
        int scienceMajorValueThomas;
        boolean thomasIsScienceMajor;
        // randomly creates thomas' statistics
            thomasGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
            thomasEssayScore = essayScore.nextInt(6);
            thomasCreditHours = creditHours.nextInt(131);
            scienceMajorValueThomas = scienceMajor.nextInt(2);
                 if (scienceMajorValueThomas == 0)
                     thomasIsScienceMajor = true;
                 else
                 thomasIsScienceMajor = false;
             // new scholar object created from existing attributes
             Scholar thomas = new Scholar("Jefferson, Thomas", thomasGpa, thomasEssayScore,
                                          thomasCreditHours, thomasIsScienceMajor);
             System.out.println("New student added - " + thomas + "\n");
             // returns all 3 students scores to show proof that the Scholar.max method is working right
             System.out.println(thomas.getFullName() + " scored " + thomas.getScore());
             System.out.println(abraham.getFullName() + " scored " + abraham.getScore());
             System.out.println(george.getFullName() + " scored " + george.getScore() + "\n");
             // highest score of all three scholars
             Scholar.max(abraham, george, thomas);
    }Thanks for reading this long and boring project.

    On comments: don't include a comment that just repeats syntax:
    // constructor for a Scholar object
    public Scholar(String myFullName, ...Anyone knowing Java syntax doesn't need that comment and gains nothing
    from its presence, and anyone not knowing Java syntax shouldn't be reading
    a listing.
    On parameter names: a isn't very imaginative or prescriptive. (See next code.)
    On setters returning the argument:
    public int setCreditHours(int creditHours ){
        this.creditHours = creditHours ;
        return creditHours;
    }1. Most people keep it simple and use a void return type.
    2, The next most common convention is to return this:
    public Scholar setCreditHours(int creditHours){
        this.creditHours = creditHours ;
        return this;
    }Then you can chain calls, which is occasionally useful:
    scholar.setCreditHours(4).setEssayScore(2);3. If you insist on returning the argument, note that this is a one-liner:
    public in setCreditHours(int creditHours){
        return this.creditHours = creditHours ;
    }

Maybe you are looking for

  • Can MRP run without Planning File Entry?

    Hi,     I came across an issue where MRP is running accurately without any Planning File Entry for a material in E.C.C.6.     My Understanding is MRP can NOT run w/o PFE u2013 which is a mandatory prerequisiteu2026..BUTu2026??? TRY itu2026   1.in OMD

  • VISA data types not compatible with ODBC SQL_C_ datatypes

    This is strange: I have a CVI app which reads data from Access 2.0 into VISA datatype structures throught ODBC 3.51 and so far it worked properly but when I upgrated the ODBC drivers to 4.0 (the application remins the same exe) then all cases where I

  • How to install msi files

    How to install an .msi file to view web tv on mac from an operator

  • Does iTunes match count against my data plan?

    I subscribed to iTunes match last week but I haven't been able to locate any information on whether or not it counts towards my data plan when I am listening to music on a non-WiFi connection. Presumably, if I am not connected to WiFi and I want to p

  • Sorting columns, editing data, and sorting back to how it was.

    I have a list that I put into numbers with their respective invoice numbers. However, these invoices go according to when the invoices were reconciled to the bank account, not their creation date, so they are out of order. I can arrange them by order