How can I use staitc method?thanks!

here is my code :
class a
void go()
System.out.println("now you are calling a.go method!");
public class b extends a
public static void main(String args[])
a t1=new a();
t1.go();
It can be compiled and excuted perfectly,but I read from book that "in static method ,we can olny call static variable or method....." ,but t1.go() method is not static method ,why? thanks!

static methods cannot refer to the methods and variables in their scope. They can however instantiate an object and use it... just like you did in your code.
Think about this.
public class SuperString extends String{
  public static void test(){
    String hello = "Hello";
    System.out.println(hello + " The string length is: " + hello.length());
}in this example whe have String class that we added a static function to. It is otherwise the same thing as a String. Notice how I can instantiate and use a String class, but If I tried something like this
public class SuperString extends String{
  public static void test(){
    System.out.println(this + " The string length is: " + this.length());
}it would fail.

Similar Messages

  • What is inner class ,and how can I use it?thanks

    what is inner class ,and how can I use it?thanks

    Theres a whole chapter here http://developer.java.sun.com/developer/Books/certification/certbook.html (thanks to SSvetlana for pointing this one out).
    Col

  • What is package,and how can i use it ?thanks !

    what is package,and how can i use it ?
    thanks

    A package is just a way of organizing your code. You organize the code in directories. For example if you have a package called "package database.util" you should put the Java code in a directory called "database/util/".

  • How can i use C# method to SAP IDoc

    Dear Friends
    i have to do one scenario in which i have to connect to database let us say SQL Server but i can't touch Database directly i can call a C# method(3rd party application is in .NET) and using XI i have to send it to SAP iDOC.
    can any one help me in this how to proceed
    Thanks in Advance.
    Ishika

    <i>Do you have any document for that on how to do it with webservices.</i>
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024f79
    See this
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2131 [original link is broken] [original link is broken] [original link is broken] [original link is broken]
    Regards,
    Prateek

  • How can I use instance methods created with HashMap

    class Template
    static HashMap customer;
    a few methods created various customer
    public static display() //to display a particular customer information among i've created above
                 String objectName,currentObjectName;
              Customer customer;
              Scanner scan=new Scanner(System.in);
              System.out.print("Please enter the customer name");
              objectName=scan.nextLine();
              Iterator iteratorForCustomer=CustomerMap.entrySet().iterator();
              Map.Entry customerEntry=(Map.Entry)iteratorForCustomer.next();
             while(iteratorForCustomer.hasNext())
                    customerEntry=(Map.Entry)iteratorForCustomer.next();
                    if(objectName.equals((String)customerEntry.getValue()))
              System.out.println("Name : " +customer.getName()); //I'm trying to reference to an instance method getName() here but i can't do that .
    }The problem is I've created as many as I want and later in the program I tried to redisplay a particular customer information based on the input (objectName). User type in the objectName and I tried to look for a particular customer Object in the HashMap and display only the relevant customer information. Is there any way to do it ? Thanks everyone in advance.

    Peter__Lawrey wrote:
    use the get method
    [http://www.google.co.uk/search?q=map+tutorial+java]
    [http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html]
    And then either look at a generics tutorial, or, if you're stuck on a pre-1.5 version of Java, find out about casting

  • How can I use Object's methed by OO4O

    I have done a type as following
    create or replace type classteacher as object
    tchid number,
    tchname varchar2(30),
    tchhomepage varchar2(100),
    tchsex varchar2(4),
    member procedure getCourseList(crslist out sys_refcursor)
    and the method is define as following
    create or replace type body CLASSTEACHER is
    member procedure getCourseList(crslist out sys_refcursor)
    is
    begin
    open crslist for
    select a.crs_id,a.crs_name,a.crs_notice
    from tb_courselist a,tb_teacher b
    where trim(a.tech_name) = trim(b.name)
    and b.teacher_id = tchid;
    end;
    how can I use the method by OO40 in vb.net.

    What is that post supposed to be?

  • How can I use phonetic fonts for cursors name

    Hi all!
    I need to use phonetic characters in cursors names. Does somebody know wich font I have to use for this ?
    One other problem is that I need to use Vietnamese characters at the same time. Is it possible to change the font of the cursors names run-time (in the diagram)?
    Last quetion: Does LabVIEW support unicode? If yes,how can I use it?
    Thank you for your help!
    Nico

    > Effectively, dual-byte encodind is allright to support Vietnamese and
    > Western languages. But how did I get the phonetics characters? With
    > shortcut key ?
    > As I need the user to change the cursor name run-time without using
    > the frontpannel cursor legend, I'm using property node and a subVI
    > asking for this name. (The user will enter the name in a string
    > control).
    > Moreover I would like the user to have the possibility to choose a
    > character in a pannel (something similar to the menu 'insert symbol'
    > in MS Word). Is it possible to do this ? With Active X maybe, but I
    > don't know which activeX objet I can use....(I am not very familiar
    > with ActiveX).
    Unfortunately, I don't know what the phonetic characters look like, so I
    can't
    tell you what to type to enter them. If you find them in Word,
    you should be able to copy them to the clipboard, they will be in
    Unicode, and paste them into LV -- where they will be converted to dual
    byte. If it doesn't work, try to find out if they are exist in the
    locale of your machine, or more importantly, the target machine.
    If you can display them, you can build a simple ring with short strings
    containing the phonetic characters. When the user picks something from
    the ring, use the strings property and value to index out the string and
    replace/append to the string the user is editing. You will want to pay
    attention to the string's selection if this is supposed to act like a
    character palette and either do an insert or replace.
    If you want a more compact grid menu, you will need to convert the
    strings to images and paste them in a pict menu. That value can be used
    to index a constant array that matches the order in the pict ring.
    Greg McKaskle

  • How can I use Method in the bean

    Hi every one
    please I made a method in for example employees entity "EmployeesImpl"
    the name of method getmax() it return number
    how can I use it at the bean
    for eaxmple when I want to press button give me the value from this method
    sorry Iam still beginner
    thanks in advance

    Thanks sir for your response
    my version
    oracle jdeveloper reales 1 (11,1,1,4,0)
    I use business component
    I make method
    this metod wrote at enitity "EmployeesImpl"
    public Number getMax() throws JboException
    PreparedStatement stat=null;
    ResultSet rs=null;
    try {
    String sql="select max(EMPLOYEE_ID)+1 from EMPLOYEES";
    stat=getDBTransaction().createPreparedStatement(sql, 1);
    rs=stat.executeQuery();
    if (rs.next()) {
    return new Number (rs.getInt(1));
    } catch (Exception e) {
    // TODO: Add catch code
    //e.printStackTrace();
    throw new JboException("error");
    } finally {
    try {
    rs.close();
    stat.close();
    } catch (Exception e) {
    // TODO: Add catch code
    //e.printStackTrace();
    // oracle.jbo.domain.Number
    return new Number (1);
    I made a jsf page
    and I put button at the page
    I want when press the button give me message contain the number which come from previous metod
    thanks my dear

  • How can I use srvctl command line for change "Failover type" and "F method"

    Hi all,
    I am using Oracle One Node (11.2.0.3), and I have a service:
    /u01/11.2.0/grid/bin/srvctl config service -d orcl
    Service name: orcldb
    Service is enabled
    Server pool: orcl
    Cardinality: 1
    Disconnect: false
    Service role: PRIMARY
    Management policy: AUTOMATIC
    DTP transaction: false
    AQ HA notifications: false
    Failover type: NONE
    Failover method: NONE
    TAF failover retries: 0
    TAF failover delay: 0
    Connection Load Balancing Goal: LONG
    Runtime Load Balancing Goal: NONE
    TAF policy specification: BASIC
    Edition:
    Preferred instances: orcl_1
    Available instances:
    I would like to change "Failover type" and "Failover method" to:
    Failover type: SELECT
    Failover method: BASIC
    How can I do that? Is there any graphical tool for it? Or, How can I use srvctl command line for change it?
    Thanks in advance.
    Leonardo.

    user10674190 wrote:
    Hi all,
    I am using Oracle One Node (11.2.0.3), and I have a service:
    /u01/11.2.0/grid/bin/srvctl config service -d orcl
    Service name: orcldb
    Service is enabled
    Server pool: orcl
    Cardinality: 1
    Disconnect: false
    Service role: PRIMARY
    Management policy: AUTOMATIC
    DTP transaction: false
    AQ HA notifications: false
    Failover type: NONE
    Failover method: NONE
    TAF failover retries: 0
    TAF failover delay: 0
    Connection Load Balancing Goal: LONG
    Runtime Load Balancing Goal: NONE
    TAF policy specification: BASIC
    Edition:
    Preferred instances: orcl_1
    Available instances:
    I would like to change "Failover type" and "Failover method" to:
    Failover type: SELECT
    Failover method: BASIC
    How can I do that? Is there any graphical tool for it? Or, How can I use srvctl command line for change it?
    Thanks in advance.
    Leonardo.srvctl modify service -d database_name -s orcldb -q TRUE -m BASIC -P BASIC -e SELECT -z 180 -w 5 -j LONG
    Also see
    11gR2(11.2) RAC TAF Configuration for Admin and Policy Managed Databases [ID 1312749.1]

  • I just made a new account and i placed the account in my ipod but now its asking me submit a payment method which i do not want to place because i do not want to purchase any app that requires money. how can i use my account without giving a payment metho

    now asks me to put in my payment method. i do not wish to place it in because i am not looking forward to purchase any app that needs to be paid for. How can i use my account but not give in my credit card data?

    Create a NEW account/ID using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before. Make sure you specify a birthdate that results in being at least 13 years old
      Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    More details of how:
    http://ipadhelp.com/ipad-help-tips-tricks/how-to-get-free-apps-from-the-app-stor e-without-a-credit-card/

  • How can I use my array in another method.... Or better yet, what's wrong?

    I guess I'll show you what I am trying to do rather and then explain it
    public class arraycalc
    int[] dog;
    public void arraycalc()
    dog = new int[2];
    public void setSize(int size)
    dog[1] = size;
    public int getSize()
    return dog[1];
    This gives me a null pointer exception...
    How can I use my array from other methods?

    You have to make the array static. :)
    Although I must admit, this is rather bad usage. What you want to do is use an object constructor to make this class an object type, and then create the array in your main class using this type, and then call the methods from this class to modify your array. Creating the array inside the other method leads to a whole bunch of other stuff that's ... well, bad. :)
    Another thing: Because you're creating your array inside this class and you want to call your array from another class, you need to make the array static; to make it static, you must make your methods static. And according to my most ingenious computer science teacher, STATIC METHODS SUCK. :D
    So, if you want to stick with your layout, it would look like:
    public class arraycalc
         static int[] dog;
         public static void arraycalc()
              dog = new int[2];
         public static void setSize(int size)
              dog[1] = size;
         public static int getSize()
              return dog[1];
    }But I must warn you, that is absolutely horrible code, and you shouldn't use it. In fact, I don't even know why I posted it.
    You should definitely read up on OOP, as this problem would be better solved by creating a new object type.

  • HT4145 How can I use an Airport Extreme to act as a Range Extender for an Alcatel One Touch Y800Z WiFi modem/router? I get a message saying it cannot be extended. Thank you. Arup

    How can I use an Airport Extreme to act as a Range Extender for an Alcatel One Touch Y800Z WiFi modem/router? As we live in a rural area and our landline broadband speeds are awful, I have moved on to a 3G provider in the UK (EE/Orange) and set up the wireless modem which is working very well with an iMac. I have an Airport Extreme base station which was previously connected with an Ethernet cable to the landline router, and two Airport Express stations as Range Extenders. I would now like to use the Airport Extreme and the two Express stations to extend the range of the Alcatel WiFi device. I have tried automatic and manual set up with the Airport Utility but at the crucial step for selecting a network to extend, although the WiFi device is recognised, I get a message saying it cannot be extended.
    Thank you for any help you can provide.
    Arup

    This is a problem with a lot of cheap end wifi hotspot like devices.. sometimes you can just swap the sim out to a real 3G wireless router.. that is a better approach IMHO than wireless repeater ever will be.
    In the meantime..
    Have a go with the suggestion.. place the express as wireless bridge. With a computer connected to the wifi from alcatel unit.. (I am amazed Alcatel still are in domestic market.. I thought they sold out). Set the express to join the wifi.. you do this in the airport utility.. old one is easy.. but in v6 you have to trust to luck so to speak and hope the auto setup works.. tell us if you have trouble.
    With the Express bridging.. you can then plug it by ethernet into the TC.. which will be in router bridge..
    ie
    You can then run the connection from wireless or ethernet on the TC.. and it will relay back to the alcatel for internet.. all a bit dodgy but who knows.. it may give you what you need.
    Wireless repeater is never particularly reliable in my experience. I would avoid it if possible.

  • How do i get a list of all Roles defubed under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?

     

    Sorry for the typographical mistake.
    Please read the question as:"How do i get a list of all Roles defined under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?"

  • I don't seem to be able to activate the Never Remember History in Privacy. It is set to Use Custom Settings, I change it to Never Remember History but whenever I open up options, it has reverted to Never remember history. How can I change it? Thank you

    At the moment my privacy settings are Use Custom Settings in Private Browsing mode with no third party cookies. Recently however when I log out of hotmail the msn homepage comes up. So I decided to change to never remember history settings. However, whenever I change it, it always reverts back to Use Custom Settings. Why and how can I change it?
    Thank you

    Firefox shows the "Use custom settings for history" setting as an indication that at least one of the history and cookie settings is not the default to make you aware that changes were made.
    If all History settings are default then the custom settings are hidden and you see "Firefox will: (Never) Remember History".
    You enter Private Browsing mode if you select:
    * Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    *Tools > Options > Privacy > Firefox will: "Use custom settings for history" > [X] "Always use private browsing mode"

  • I'm trying to use Dictation.  Where does the text go, and how can I retrieve it?  Thank you.

    I'm trying to use Dictation.  Where does the text go, and how can I retrieve it?  Thank you.

    You dictate after you open a blank page in any text editor. The text goes on the page.
    You can use Text Edit for example (in your applications folder).
    With the blank page open, go to the Edit menu and select Start Dictation. When you are finished, you save the file as you would any other document. You can retrieve it, edit it or anything else you want, because it is a file like any other you create with that text editor.

Maybe you are looking for

  • Reference to control on main front panel fails when subvi front panel is closed?

    Hi All, I'm experiencing an odd bug. In my code, I use a subvi to control a piece of hardware. This subvi has controls for all of the functions of my hardware. I'm changing the value of one of these controls from my main front panel by running a refe

  • DVD Drive problem

    Is it just me or are people having a lot of problems with there DVD Drives. I had mine replaced back in April, barely used the drive, went to use it tonight and its ejecting discs again. Surely it can't be gone again. Can anyone give me any ideas at

  • Data persistence using SQL/J

    Hi ! I am trying to achieve data persistence using SQL/J. The env / tools that I am using are WLS 4.5.1 Oracle 8i, SQL/J. SQL/J works fine with the two - tier applications but with WLS the connectivity is not been arrived at. Any help would be wewlco

  • I have a custom table and i have to update the table every 4 to 5 min ,

    Hi All, I have custom table and i have to update every 4 to 5min through custom program , could pls suggest the various ways to do that. Regards subba

  • Amount conversion

    Hi, I have requirement like this.Input file is coming and data is posted to SAP.But if that amount part is suppose 1037135 like this.Instead of posting amount like 10371.35 it is posting like 270.74. Please provide the answers and kindly need ful. Th