What is the purpose of Static methods inside a class?

Hi,
What is the purpose of Static methods inside a class?
I want the answers apart from "A static method does not require instance of class(to access) and it can directly be accessed by the class name itself"
My question is what is the exact purpose of a static method ?
Unlike attributes, a separate copy of instance attributes will be created for each instance of a class where as only one copy of static attributes will be created for all instances.
Will a separate copy of instance method be created for each instance of a class and only one copy of static methods be create?
Points will be rewarded for all helpful answers.

Hi Sharma,
Static methods is used to access statics attributes of a class. We use static attributes when we want to share the same attribute with all instances of a class, in this case if you chage this attribute through the instance A this change will change will be reflected in instance B, C........etc.
I think that your question is correct -> a separate copy of instance method will be created for each instance of a class and only one copy of static methods be create ?
"A static method does not require instance of class(to access) and it can directly be accessed by the class name itself"
Static Method: call method class=>method.
Instance Method: call method instance->method.
Take a look at this wiki pages.
[https://wiki.sdn.sap.com/wiki/x/o5k]
[https://wiki.sdn.sap.com/wiki/x/ZtM]
Best regards.
Marcelo Ramos

Similar Messages

  • What 's the advantage of static method.

    I think if a method is declared as static, the program should allocate some spaces for the method when the program start. However, I found many static method in an erp open source project. What make me confused is that it will cost many spaces.
    Perhaps they want to lose some spaces for speed???
    Can somebody answer my question.thanks!

    > I think if a method is declared as static, the
    program should allocate some spaces for the method
    when the program start. However, I found many static
    method in an erp open source project. What make me
    confused is that it will cost many spaces.
    Perhaps they want to lose some spaces for speed???
    Can somebody answer my question.thanks!
    To be sincere, I've never thought about performance cost when static methods are used. I decide to create and use them mainly whether I have the "feeling" that it will provide me benefits, in terms of designing. Yes, it's like a feeling. I am not able to explain you why or how I have this feeling, I'm not native in English language, so choosing the appropriate words to explain my ideas sometimes is hard to me. Besides. I admit that I am a little bit lazy in this moment, I don't want to search through some dictionary...;-).
    I think the more you develop your abilities and skills in java programming, the more you can feel, you can have this "feeling", and naturally you figure out in which situations using static methods is a better choice.

  • The purpose of static methods ....?

    In lay mans terms can anyone tell me WHY we have static methods ?

    In lay mans terms can anyone tell me WHY we have
    static methods ?Static methods become class level methods and are no longer confined within the objects of the class.
    Static methods typically provide information about the class as a whole, such as the number of created objects etcetera. Another use is as an object factory. Instead of doing new all over the program you have a static create method you call to get new objects of the class.

  • What is the Purpose of getHandle() ?

    hi ... i am not cleared about the javax.ejb.EJBObject's method getHandle() .. what is it ? what is the purpose of this method . ( i know this line that it is used to get the Handle, but what is a handle ? and why it is used and how it is used ? ) and why this method is not available in javax.ejb.EJBLocalObject

    Looking up and getting reference is time consuming in case of remote calls. You could get reference of EJB using getHandle() and cache it for further calls.
    And in case of EJBLocalObject, time consuming lookup is not needed - as they are in same memory address space.
    Regards,
    Byju Joy

  • What is the benefit of static in a method/function

    hello,
    can u explain the benefit of static in a function?
    and why i cannot called a function in a static method..example :
    class jalaninFungsi{
         public static void main(String args[])
              tesfungsi();
         public  void tesfungsi()
              System.out.println("ini tesfungsi");
    }its produce error : non-static method tesfungsi() cannot be referenced from static context
    thanks.

    A class is an object.
    So for example:
    class STUDENT
    public String getStudentName()
    return name;
    public int getStudentGPA()
    return GPA;
    In this case, to be able to call the function getStudentName() and getStudentGPA() you will actually need a STUDENT object.
    That means you must have declared e.g. STUDENT A; (in the main method for example), then to call those two functions above you'll need to write A.getStudentName(); and A.getStudentGPA();
    HOWEVER if you have static method, you don't need to create an object of that class type. You can just simply call the class name and then use the dot operator and call the function. e.g.:
    class STUDENT
    public static String getStudentName()
    return name;
    public static int getStudentGPA()
    return GPA;
    Notice that these are static methods, so to access these methods you just need to write STUDENT.getStudentName(); or STUDENT.getStudentGPA();
    Again, notice that here I don't use A . but instead I used the class name (STUDENT.)
    However, this is not logically correct in this (my) particular case to make those two methods static. You'll need to read more by yourself about the usage of static method. I am just trying to explain it to you why there is such thing called static methods in java.
    - o.z.

  • What is the purpose of Destination Function on Submit Button?(Doesn't work)

    Hi Gurus,
    There is a property "Destination Function" on Submit buttons.
    What is the purpose of this field.
    I tried setting some values here expecting following behavior in order:
    1. Process Form Request will get executed.
    2. User will be navigated to the OAF page related to the Destination Function.
    Destination Function property probably point to setInvokeFunction method of the OASubmitButtonBean.
    Please advise on this.
    Thanks and Regards,
    Prince

    Question 2. What is the purpose of View Instance on Submit Button? Is it there for BoundValues? Any examples how can we use this?
    Question 3. Related to Question 2, What is the purpose of View Instance and View Attribute on Button?

  • What is the purpose of Defining a requirement in the procedure?

    Hi
    I have a query related to the Output type .
    What is the purpose of Defining a requirement in the procedure?
    And where shall we code for a new requirement and also what shall we code in it?
    Thanks

    <b>Requirement Use</b>
    If the requirement is fulfilled (SY-SUBRC = 0), then output determination also takes into consideration output type or the access sequence, for which the requirement has been specified.
    <u><b>Output determination:</b></u>
    An object that checks whether the application data (for example, data determined in Customizing) corresponds to the condition records.
    If this is the case, one or several messages are "found," which can then be processed (for example, sent electronically).
    The condition records are searched for according to a predefined hierarchy in message determination.
    After defining a new requirement no say 604 for billing pricing procedure and activating it, the standard sap system creates a routine with the no: 604 specifically for billing. So the name of the program automatically created by SAP will have the naming convention something like RV64A604. then you need an access key to go to the change mode for writing any logic. Then just put a break-point and then execute VF01 or VF04, then the cursor position directly goes into this routine, where the pricing structures KOMK and KOMP have the visibility. So based on the values flowing inside this structures, you can probably code that suites the business requirements.
    there are some useful transactions like VOFM for maintaining the requirements and formulaes for a pricing procedure.
    For viewing the requirements in the procedure you can also go to V/08 transaction.
    Lakshminarayanan
    P.S. Reward points for all helpful answers.

  • What's the purpose for the resistor in the jack of Pismo's power supply?

    Recently the power supply of my Pismo started failing and I decided to troubleshoot it. Turned out the cable next to the jack was broken. I went on with the repairs and inside the jack I found a resistor connecting the negative terminal with the shield of the jack. What's the purpose for it? What would happened if I just removed it (I found a site that said it wasn't really necessary)?
    Andy

    After talking to a couple of experts in the field of electronics, they both confirmed tat that resistor is there in order to suppress any RF interference that the PowerBook might produce.

  • What's the purpose of javafx.util.Pair K, V ?

    Hi,
    what's the purpose of javafx.util.Pair<K, V> if we can just use java.util.AbstractMap.SimpleEntry<K, V> for the same use cases?

    You are seriously asking why you should use a proper API-class over a static inner class of some random collection class?

  • What is the purpose of  BAPI_SALESORDER_SIMULATE

    Hi Experts,
        can u please call me what is the purpose of BAPI_SALESORDER_SIMULATE.
    Thanks in Advance

    Hi,
    <b>Functionality</b>
    This method has the same interface definition as the BAPI_SALESORDER_CREATEFROMDAT1 function but differs from it in that here the sales order is not updated.
    Here you can determine availability and pricing. This data is displayed in the ORDER_ITEMS_OUT table.
    Even you can look at the Documentation of bapi in SE37
    Regards
    Sudheer

  • What is the purpose of this (?=) ?

    hi friends...
    I am practising the WDA programs...
    in that they hav used this code
    data wd_table type ref to cl_wd_table.
    wd_table ?= view->get_element( 'TABLE' ).
    wd_this->table_control ?= wd_table->_method_handler.
    wd_this->table_control->set_key_attribute_name( 'MATNR' ).
    i don't know why they used this code...
    here  ( ?= ) what is the purpose of this ?= ?
    what is the purpose of this class cl_wd_table ?
    i am not clear with all statement, can you guide me..
    i am waiting for ur reply
    regards
    Deva

    ?= this is called downcast or narrow casting operator in abap.
    The purpose of this is assignment between reference variables in which the static type of the target varible more specific than the static type of the source varible.
    Check this link, hope it helps !
    [https://help.sap.com/saphelp_nw70ehp1/helpdata/en/c3/225b5f54f411d194a60000e8353423/frameset.htm]
    Radhika.

  • What is the purpose of your business? For logo design?

    What is the purpose of your business? For logo design?
    Can anybody reply the best message in this...

    Hi Kittu,
    There may come a requirement of creating a new attribute or method of a Business Object which doesn't exist in the standard Business Object.
    In these cases, you may have to create a sub-type of Business object and write your own code(logic) for attributes or methods.
    Clarifications are welcome.
    Thanks
    Venkat

  • While defining a columnar table, what is the purpose of column store type

    Hi folks
    I have two questions related to columnar table definition.
    1. What is the purpose of column store type.
    While defining a columnar table, what is the purpose of column store type (STRING ,CS_FIXEDSTRING,CS_INT etc) , when I define a table using the UI I see that the column is showing STRING but when I goto EXPORT SQL it does not show.  Is this mandatory or optional ?
    2.VARCHAR Vs. CHAR - In the UI when I create the table I do not see the CHAR option , but I do see lot of discussion where people are using CHAR for defining the columnar table. Not sure why UI dropdown does not show it. I also read that we should avoid using VARCHAR as those columns are not compressed, is that true, I thought the column store gives compression for all the columns. Are there certain columns which cannot be compressed .
    Please let me know where I can find more information about these two questions.
    Poonam

    Hi Poonam
    the CS_-data types are the data types that are used internally in the column store. They can be supplied but it is not at all required or recommended to do so.
    SAP HANA will automatically use the correct CS_-data type for every SQL data type in your table definitions.
    To be very clear about this: don't use the CS_-data types directly. Just stick to the SQL data types.
    Concerning VARCHAR vs CHAR: fixed character data types are not supported anymore and don't show up anymore in the documentation.
    I have no idea why you believe that VARCHAR columns are not compressed but this is just a myth.
    create column table charcompr (fchar char(20), vchar varchar(20));
    insert into charcompr (
        select lpad ('x', to_int (rand()*20), 'y'), null from objects cross join objects);
    -- same data into both columns
    update charcompr set vchar = fchar;
    -- perform the delta merge and force a compression optimization
    merge delta of charcompr;
    update charcompr with parameters ('OPTIMIZE_COMPRESSION' ='FORCE');
    -- check the memory requirements
    select COLUMN_NAME, MEMORY_SIZE_IN_TOTAL, UNCOMPRESSED_SIZE, COUNT, DISTINCT_COUNT, COMPRESSION_TYPE
    from m_cs_columns where table_name ='CHARCOMPR'
    COLUMN_NAME    MEMORY_SIZE_IN_TOTAL    UNCOMPRESSED_SIZE   COUNT   DISTINCT_COUNT  COMPRESSION_TYPE
    FCHAR       3661                    70285738            6692569 20              RLE
    VCHAR       3661                    70285738            6692569 20              RLE
    We see: compression and memory requirements are the same for both fixed and variable character sizes.
    - Lars

  • What is the purpose of open/close connection data socket?

    Hello everyone,
    I am writing and reading values in OPC Server through data socket. What is the purpose of open/close connection data socket when writing /reading a value?  Without the open/close connection element, it still work correctly. I am writing values in the server thru event stucture.I do not need any buffered reading or writing. What will happen if I didnt not use the open/close connection? Maybe it may cause some problems in my program which i didnt realise? 
    And I have attached an example of my program. Thanks
    Yehchia
    Attachments:
    Test Event.vi ‏11 KB

    Hi YehChia,
    I was talking about something like that:
    1. Not good. since with every iteration the DS connection needs to be opened and closed.
    2. Good. Since you open the connection only once then do the reads and close it afterwords.
    Christian

  • I want to transfer all my iPhoto, iTunes, contacts, etc. files from my MacBook, which I am selling to a MacBook Pro. What is the easiest and safest method of achieving this? Can the files backed up on Time Machine be transferred to the Pro?.

    I want to transfer all my iPhoto, iTunes, contacts,documents, etc. files from my MacBook, which I am selling, to a MacBook Pro. What is the easiest and safest method of achieving this? Can the files backed up on Time Machine from the MacBook be transferred to the Pro in some way? I would like to capture the files as they appear on the MacBook, such as "Events" in iPhoto and the various song categories within iTunes without having to rename them all once saved on the Pro, which is the case with photos when I simply save them to thumb drive and import them to the Pro. Sny advice would be appreciated.
    Best regards,
    Rob.

    Michael,
                 Thanks for all your assistance. There is no need for apologies, Migration Assistant did indeed create a second account for the MacBook data. It has just taken me some time to figure out how to access it. I now have all the MB data in one account and the MBP files in another, which suits me fine. In fact, it is an advantage in my case as it keeps the private and business aspects separated.
    I will however try the fatcatsoftware to transfer all the iPhoto files to my iMac, where I keep my main photo library. and it will be of help to keep the events, etc in the transfer. As far as iTunes is concerned, I have HomeSharing on all my computers and this has obviated the need to worry about playlists being transferred successfully. However, HomeSharing did not appear to share the iPhone/iPod apps that were stored on the MB and although these have now come across with the new MacBook account on the MBP, I was wondering whether my iPhone and iPod will be recognised by the MBP and sync with it? Will I need to have the MB account open to achieve this or will the MBP recognise and sync with the iPhone/iPod automatically irrespective of which account is open?
    Thanks for the tip on deauthorising my iTunes account from the MB before sellng. This I will do and I believe the best way to remove all of my data from the hard drive is to reinstall the MacOSX operating system software. Is this the right approach to securely delete everything?
    Thanks again for sharing your expertise and your guidance through this exercise.
    Best regards,
    Rob.

Maybe you are looking for