Simple Method/Object Concept Question

I really appreciate everyone's help! Thanks you. I know that for action to take place in Java objects, blocks of code called methods are used. Methods tell an application what to do when buttons are clicked, menus are opened, and text is typed. Methods are either predefined or are created from scratch to manipulate objects, or the data within those objects, but what does the data type identifier that is attached to java methods mean? What is the data type identifier?
Also, what are the major components of an object? I know objects are based on classes that detail how the object is defined and how it behaves. It is starting to click, but I need more explanation. Thanks a lot
Stephen

The datatype of the method represents the datatype of the value returned or void if nothing is retured. Consider the following: int getAge() In this case, the method getAge() will return a value that is an integer. If the method does not return a value, void is used as in the following line:void setAge(int age)As far as the "major parts of an object", well there can be many answers to that. One answer comes from the simple definition of an Object, i.e., "data surrounded by code". In other words, an object is a person, place or thing (or process). The object has sate (data about itself) and it has behavior (code or methods). In that respect, the major parts of an object, in it's simplest form, are it's state (member variables) and it's behavior (member functions/methods).
Hope this helps.

Similar Messages

  • Simple, funny but annoying question, putting a pixel

    Maybe this could be simple, funny but annoying question.
    How do you put a pixel or draw a pixel?
    Is there a method to draw a pixel directly on screen in j2SDK API?

    This is a very open ended question, do you want to draw a pixel in an image or just draw a shape on the screen?
    If you want to edit single pixels at a time then the best option is to create a BufferedImage and use the WritableRaster to edit the pixels you want by using setPixel().
    Something like the following:
    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = img.getRaseter();
    raster.setPixel(x_coord, y_coord, new int[]{R_val, G_val, B_val});This image can then be displayed by putting it in a JLabel (there are many other techniques but I find this the easiest method).
    JLabel l = new JLabel(new ImageIcon(img));
    JFrame jf = new JFrame();
    jf.setContentPane(l);
    jf.pack();Alternatively, you can draw shapes by using Graphics or Graphics2D objects
    e.g.
    public class MyPanel extends JPanel
      public void paintComponent(Graphics2D g)
         super.paintComponent(g);
         g.drawLine(x1,y1,x2,y2);
    }Hope this helps,
    Stef

  • Concept Question about EDI and Error Processing

    Hello All,
    This is a concept question, I was wondering how others would approach this scenario.
    Let's take this scenario. In EDI often the transmission for a purchase order comes in with an invalid material number. Normal error processing is for the EDI team to research the issue (find the correct matnr), edit the idoc and reprocess the Idoc.  I would like to move that type of error processing out of the hands of the EDI folks and into the hands of the business users.
    How would they correct the material number? It has to be more intuitive than editing an IDoc, it has to be an easy and intuitive user interface. This process has to also work for many types of EDI transmissions both inbound and outbound.
    There would be many ways to handle this: create a report with an editable grid that would change the idoc during input and create the order with the corrections, convert the idoc to xml and use simple transformations, use an xsl report...etc.  You get the point. 
    How would you approach this?  Before I start the design I want to make sure I've given all the options due consideration...all options, webdynpro, transformations, regex, you name it...all is available, except there is no XI. 
    Personally I'm leaning towards an editable grid and processing buttons that would post the idoc in background...but I do that type of thing all the time and I may be in a rut and neglecting better design options.
    Thanks for your input,
    Greg

    <b>Paul:</b> So it runs the transaction silently in BDC format, until the error occurs, then opens up in dialogue to allow the user to change the invalid material, and then continue on with processing.
    This works when the processing function module uses BDC. But even then I think this is possibly nice from user perspective, but a nightmare from auditing perspective. I.e. correct me if I'm wrong, but I'm pretty sure there's no log indicating that the user changed the material number. Thus for anybody comparing the IDoc contents against the posted document (including change history) there's no trail that shows this change. Of course you can assume that this is what must have happened, but I personally prefer if I can track in the system what happened and have proof for that.
    <b>Reddy:</b>
    <ol>
    <li>it can be run daily basis, which should select all idocs which are in status 51 with message number (..related to wrong material number). report output should inlcude :idoc number-wrong mat no- space for new material to be entered by business against wrong 1. And there should be one button for RUN.</li>
    <li>After RUN, the material number should be changed to new 1 in segments and idocs should be reprocessed.</li>
    <li>repeat the run until business enter right mat num.</li>
    </ol>
    Design seems to limited to me (takes care only of one error message). Might work if that's the main pain point and this is the only one the user is dealing with. Otherwise I'd expect pretty soon they start complaining about having to use different tools for the possible errors. I'd keep the report more general, but allow this special form of processing only for a given error message (otherwise it's a normal re-process as triggered for example via BD87).
    Also, I assume that when you talk of changing the IDoc you mean that you actually keep an original copy around (like SAP does when you edit an IDoc). Often this is required from an auditing perspective. I'm not sure why you wouldn't want to check the material number <em>before</em> trying to process the IDoc to avoid wasting system resources (but maybe I misunderstood the step).
    Anyhow, in theory you could also achieve all of this via workflow. You can add custom columns to the work item overview in the inbox, only issue here is that it doesn't scale well (so issues with larger volumes).

  • Why no simple method for reading text files

    I'd like to know, after all this time why there is no simple method of reading ext files into a string.
    Yes, yes, I know all about buffered readers, (it took me long enough to figure them out) but they are cumbersome and seem to change every release (how many file methods have been deprecated...)
    Here's what I'm looking for:
    file.open();
    file.read(String);
    file.close();
    No single character at a time, no loop - the whole file into a single string in one shot. If buffers are used, i want it hidden.
    Perl, PHP, VB, C# all have this. Even Java has it when you write to a file.
    So why not on read?
    Yes, buffered streams are very elegant, but for what most programmers want to do, they are overkill and annoying.

    Just Dennis Ritchie's little joke.
    Do you have a better reason for wanting the feature
    other than that some other languages have it?Yes. It would save me time and help dozens of new programmers who continually ask this question in this and other forums. It is in other languages because people use it and want it - clearly Jarkata saw the need. If you don't like the idea, then I won't argue the point. We agree to disagree.
    Also did you have an answer for my question?in java.io.file you can do the following: (i've used it, it works) Granted, you still have to use the buffered output streams, which in my opinion should be abstracted for a simple text read and write.
    BufferedWriter outputStream = new BufferedWriter(new FileWriter(fileNewPath));
    outputStream.write(fileContent);
    outputStream.close();

  • Anyone heard of static Constructor? Pure Concept Question

    Hi All,
    I guess this is a little obscure but let me ask this anyway.
    Has anyone heard about a "static constructor"? No I am not talking about a static block in your code. I am talking about a static method which will be called every time you make a static call on a particular class. Just like the constructor gets called every time you create an Object. The difference will be that the static code will be executed only once while the static constructor will be called every time you call a static method.
    My question: Do you see a need, from the experience you have got, about such a construct being a feature of a language? I was talking to some people of a very well known company - who were telling me about this special feature - as they put it - being part of their Proprietary language. They couldn't convince me as to why this "special" feature was required. I seek help from the Community to help me think about this. I tried seeking an answer to this question on the net but to no avail.
    I for one, am not going to stop my quest after posting here - but I would be grateful if any of you could help me.
    Thanks for all your support.
    Best Regards,
    Manish

    Hi All,
    I am overwhelmed by the response. Thanks for spending your time thinking about this.
    Some of the questions you asked were...
    teknologikl : Did the people say about how is it useful?
    javax.pert : No. They tried to tell me things like initializing static objects which I could have as well done in a common method which I call in the start of every static method. Basically they could not convince me about the use of a static constructor. May be they did not know too well why it was put in the first place. Because I was talking to programmers rather than Designers. But I did not want to stop at that. I wanted to tickle my gray cells and yours to find out why would someone put this as part of a language? I agree with most of your posts but instead of telling me that this is not going to be very useful ( which I already thought of), I would appreciate if you can help me think Why would someone have put it at all. You see what I am saying?
    rjwr: static factory methods
    javax.pert: Yup. I am aware and use static factory methods. But this is a little different. This is called automatically by the VM - just like a normal constructor - whenever a static method is called.
    dubwai: This sounds pretty lame to me...
    javax.pert: Sorry if I wasted your time. But please look at my response to teknologikl above.
    DrClap:
    javax.pert: Yup, yup. I thought just the way you are saying. I am actually trying to get in touch with some one who knows more about this proprietary language - maybe one of the designers. I would be glad to share the findings when it comes - if it is worth sharing of course. Thanks for your time though. :)
    rvflannery: Security framework.
    javax.pert: True. I agree with you about this being a wrapper for security purposes. Maybe this is what they thought of. One reason I see is that because they expose the APIs to third party vendors. These APIs can talk, by extending certain objects, to the sensitive areas of the database. I guess this could be one of the reasons. I will share it once I know more about it.
    trejkaz: For debugging.
    javax.pert: See my answer to rvflannery above.
    Thanks all of you for spending your time with me. I will keep you informed whenever I get something worth sharing.
    Thanks again,
    Best Regards,
    Manish

  • Locking on Method objects?

    my understanding is that:
    public synchronized void counter() { usageCounter++;  }is equivalent to:
    public void counter() {
      synchronized(this) {
        usageCounter++;
    }locking the whole object has some overhead. could this overhead be eliminated using this approach:
    public void counter() {
      Method m = this.getClass().getMethod("counter", new Class[0]);
      synchronized(m) {
        usageCounter++;
      } // and this method is the only way to modify "usageCounter"
    }what exactly does this do?
    my understanding is that a Method object is static and immutable . they are created when the relevant class is loaded.
    so, it really makes no difference that i sync on the " +counter()+ " method object when i am in " +counter()+ ". right? i could just as easily sync on maybe the " +counter123()+ " method object.
    btw, do immutable objects have mutable locks? my code compiles/runs correctly. though, i've not done extensive testing to see if i get a "ConcurrentModificationException"
    anyway, this is all hypothetical. just trying to learn about java. and maybe someday i can answer, rather than post, questions.
    thanks.

    what exactly does this do?Uses a Method object as a lock. Note: a Method is only a representation of the compiled method. You cannot get access to the compiled method.
    Method object is static and immutable .Its neither. You can have more than one per real method (not static in any sense of the word) and they are mutable. e.g. setAccessible()
    they are created when the relevant class is loaded.No. When the class is loaded, neither the compiled method (created when you call the method) nor the Method object are created are loaded (The first Merthod is created the first time it is needed and then copied as required, the Class has a soft reference to a cached copy which means the cached copy is discarded on a full gc, potentially recreated later)
    it really makes no difference that i sync on the " counter() " method object when i am in " counter() ". right? Locking on a object means different threads can be accessing different objects at once, but two threads cannot access different synchronized methods on the same object at once.
    In your case you have the opposite. Different thread would not be able to concurrently access a method (even for different objects) but would be able to access different methods of the same object.
    Except, as Method is mutable, getMethod() returns a different object each time, so your lock effectively does nothing.
    The purpose of synchronization is to protect mutable data i.e. fields of an object, not protect methods.
    immutable objects have mutable locks?All objects have locks, immutable object are no different. (Java doesn't know the object is immutable, perhaps it should, but it doesn't)
    i've not done extensive testing to see if i get a "ConcurrentModificationException"You could be waiting a while as this only occurs on Iterator for some collections. Note: you can get this exception with just one thread.
    just trying to learn about java. and maybe someday i can answer, rather than post, questions.This is a good place to do that.

  • ActiveX in BradySoft (CodeSoft) - What Class/Method/Object's would I use to send variable form data to BradySoft?

    What Class/Method/Object's would I use to send variable form data to BradySoft? I have a basic label setup in BradySoft and I want to send it variable form data (a serial number) from Labview ActiveX. I have attached Brady's ActiveX programmers guide but can't figure out what to use for this. P.S. I would call Brady or TekLynx tech support about this but they have a strict policy whereas BradySoft supports ActiveX but their tech support doesn't provide programming help with it. I figured I'd try the NI Forums.  

    Aaronb, I presume by publishing an ActiveX programmers manual the BradySoft software installs Active X objects. You may choose to interact with these objects within LabVIEW using Active X controls. The following link will provide a starting point for LabVIEW help topics on Active X communication: Select ActiveX Object Dialog Box
    http://zone.ni.com/reference/en-XX/help/371361F-01/lvdialog/insert_active_x_object/
    Building a Simple Web Browser Using ActiveX (Example of ActiveX arcitecture)
    http://zone.ni.com/devzone/cda/epd/p/id/81 Hope this helps provide a bit of guidance. Cheers!  

  • What's wrong with this simple method

    i'm having compile troubles with this simple method, and i think it's got to be something in my syntax.
    public String setTime()
    String timeString = new String("The time is " + getHours() + ":" + getMinutes() + ":" + getSeconds() + " " + getIsAM());
    return timeString;
    this simple method calls the get methods for hours, minutes, seconds, and isAM. the compiler tells me i need another ) right before getSeconds(), but i don't believe it. i know this is a simple one, but i could use the advice.
    thanks.

    Hi,
    I was able to compile this method , it gave no error

  • Need help regarding Value Object Concept in flex/java

    I need to map the java objects to flex use value objects in flex.
    The problem is I have a class in java which is referring to another class and again that class referring another class.
    For instance
    Class A
         protected User user;
    Class User
         protected Address address;
    Now I need to map class A to the flex using value object concept and I have to display the user info in the grid as well.
    Need some help to get started.

    You need to set the "scope" property in your remoting destination definition to "session" or "application".

  • Hi when I stream video content to my Tv using Apple from my Ipad3 I find the Ipad goes to sleep after 2/3 minutes and disconects, the only way I have found to stop this is to continually tap the Ipad screen but there has to be a simpler method/ any help

    Hi when I stream video content to my Tv using Apple tv from my Ipad3 I find the Ipad goes to sleep after 2/3 minutes and disconects, the only way I have found to stop this is to continually tap the Ipad screen but there has to be a simpler method/ any help would be most welcome.

    Welcome to the Apple Community.
    Contact the developer of the Air Video app.

  • HT1692 I want to use my reminder folder in simple method with has come with I pad .i m facing the problem after update of software

    I want to use my reminder folder in simple method .witch I have received with iPad .after update of software now the. Window is different .plz help me to resolve
    the same.

    Read how the new Reminder function works here:
    iPad User Guide - For iOS 7 (October 2013)Nov 1, 2013 - 23 MB

  • Java Usage Concept Questions

    I have a java Command line running program. Which allow input/edit data of clients and store them into a Flat file. The problem is that i have to make a GUI, ( a thin web based client ) and using only HTML and Javascript.
    The next step is the db should be frontended by servlet or JSP that interact with thin client to perform the database retrievals.
    Now my concept Questions:
    1. Is it possible to communicate to a Java Program using HTML and Javascript? If so, any exampler, pointers?
    2. I was thinking of using HTML and Javascript to directly modify the Database. ( Since it is a flat file therefore nothing more than a txt file ) But isn't this side stepping the problem?
    3. If i could modify the Flat file using HTML and Javascript only. Why would i need JSP and Servlets? And if i could do it with JSP and Servlets only why would i need the think client ( HTML bit )?
    If all of above 3 are correct ( conceptialy ), what is the orginal command line java program for?
    The last question is why i think i have the concept wrong. Please i am new to web programming so feel free to point out any error.

    Hello,
    You a little off on a few things. let me explain what each is used for to give you a better idea what each i used for.
    HTML - Used to format data. Is static and can't do any File I/O and such
    Javascript - Is usaually used for client side validation and some cool effects.
    JSP - Is a scripting language that allows you to execute code on the server to create dynamic content and server side stuff like saving to a DB or a file
    Servlets - Kinda like JSP but gives you more control over a few things. Usaually used for form processing and Servlet/Applet communication
    for you application i would probably embed HTML/JavaScript for layout and validation into a JSP page for your display pages.. then build JSP pages to handle all you business logic and processing.
    --Zer0C00L                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Docs about RowSet, and Object RowSet questions?

    Docs about RowSet, and Object RowSet questions?
    I can find RowSet forum, so I ask here!
    Can you give me URLs where I can find more about RowSet and URLs for any RowSet implementation?
    Does Borlans, Oracle, IBM, etc., have RowSet implementation?
    I find out about Sun's RowSet implementation, but I can't find Object Rowset in this implementation?
    Is it possible to develop Object RowSet and is it useful?
    I know about O/R tools like Hibernate, but Object RowSet can be useful?
    Run SQL query and get Objects, or maybe even run Object query (like EJB or Hibernate or JDO have) and get Objects.
    No XML mapping mess and simmilar, like with EJB or Hibernate or JDO?

    You can try
    http://java.sun.com/developer/Books/JDBCTutorial/chapter5.html
    This is a tutorail for RowSet

  • Replicating simple Java objects for automatic failover

    Is there a way to replicate a simple java object that is bound from JNDI
              across all servers so that if the primary server fails, it will
              automatically failover?
              We have a java client that uses JNDI to access EJBs on WLS5.1 SP8. In order
              to determine client information, the client currently binds a simple java
              class in the JNDI tree. The Entity and Session beans use the caller
              principal to locate the object in order to access client-information for
              such things as record locking, logging, etc..
              We have to move this architecture to a cluster environment and we are
              wondering how we can replicate this object across cluster servers so that
              failover is handled automatically, and that it is still accessible through
              JNDI.
              An RMI replicated stub is not enough, since it only works as long as the
              server hosting the RMI object is alive.
              I'd like to add that the object is created and bound at client start-up and
              destroyed at client exit.
              Thank you for any advice or information,
              Dania Kodeih.
              

    A: Replicating simple Java objects for automatic failover

    That's what I figured. I guess the only solution in this case is to persist
              the object during client sessions. I was hoping for something simpler, but I
              guess I'll have to create an Entity Bean and everything else that comes with
              it.
              Thanks,
              Dania.
              Cameron Purdy wrote in message <[email protected]>...
              >Unfortunately, when the originating server goes down, the replicated object
              >disappears.
              >
              >Peace,
              >
              >--
              >Cameron Purdy
              >Tangosol, Inc.
              >http://www.tangosol.com
              >+1.617.623.5782
              >WebLogic Consulting Available
              >
              >
              >"Don Ferguson" <[email protected]> wrote in message
              >news:[email protected]..
              >> If I am not mistaken, any serializable object will automatically be
              >replicated
              >> across the tree.
              >>
              >> Dania Kodeih wrote:
              >>
              >> > Is there a way to replicate a simple java object that is bound from
              JNDI
              >> > across all servers so that if the primary server fails, it will
              >> > automatically failover?
              >> >
              >> > We have a java client that uses JNDI to access EJBs on WLS5.1 SP8. In
              >order
              >> > to determine client information, the client currently binds a simple
              >java
              >> > class in the JNDI tree. The Entity and Session beans use the caller
              >> > principal to locate the object in order to access client-information
        �... [Show more]

    Read other 4 answers

  • Serializing the Method object

    Hello.
    I need to serialize the Method object, but as i have no access to it, does it mean that i will not be able to do anything?

    Yes. that's what i thought.
    Instead i created an Externalizable class that contains my Method, and i do the marshalling/unmarshalling by myself.
    Has anyone got an idea of why they did not make it serializable? Is there a reason, or is it just because they forgot?

Maybe you are looking for

  • [svn:osmf:] 10751: Fix a bug with the ReferenceSample project.

    Revision: 10751 Author:   [email protected] Date:     2009-09-30 10:57:34 -0700 (Wed, 30 Sep 2009) Log Message: Fix a bug with the ReferenceSample project. Modified Paths:     osmf/trunk/apps/samples/framework/ReferenceSample/org/openvideoplayer/mode

  • Issues changing the lettering on the main menu

    Hello I created a website www.franciscobulgarelli.com a year ago, I went back and added some new pages but I'm having a hard time making the letter size uniform, I go on the main menu to change it but it doesnt seem to respond, the 2 new pages, narra

  • [JS] CS3 file.openDialog ()

    What folder does file.openDialog default to? I can't seem to find any consistency in this. And is there any way to control it?

  • Want to create a small Movie to play on ipod

    Hallo I want to create a small Movie-file to play on my iPod, but I don't want to use the quite large Standard iPod-Format. What other choices do I have? I tried MPEG4, but it didn't play. I produce a Videopodcast, and want to keep the size small, an

  • CE-505 w/Microsoft Proxy Server Authentication

    Recently installed Cisco CE-505 and the customer wants to direct everything to Microsoft Proxy Server for authentication and URL filtering with SurfControl. I added the command: http proxy outgoing host 192.168.90.2 80 primary - which directs all HTT