How do I make a static reference to a method?  Sample Code Included

Why doesn't this work? How do I use the method add(int a, int b)?
ERROR - "Can't make static reference to method int add(int, int) in testClass"
interface testInterface{
    static String sString = "TESTING";
    int add(int a, int b);
class testClass implements testInterface{
    public int add(int a, int b){
        return a+b;  
    public static void main(String argv[]){
        int sum = add(3,4);    // here's the error
        System.out.println("test");
        System.out.println( sum );
}

Why doesn't this work?Because you can't call a non-static method like add (which operates on the object called this) from a static method like main (for which there is no this).
There are two ways to fix this:
(1) In main, create a TestClass object, and call add() for that object:
class TestClass implements TestInterface {
   public int add(int a, int b) {
      return a+b;
   public static void main(String[] args) {
      TestClass testObject = new TestClass();
      int sum = testObject.add(3, 4);
      System.out.println("test");
      System.out.println(sum);
}(2) Make add() static. This is the preferred approach, because add() doesn't really need a TestClass object.
class TestClass implements TestInterface {
   public static int add(int a, int b) {
      return a+b;
   // main is same as the original
}

Similar Messages

  • How do you make a static reference to a method?  I've included code.

    I'm sorry but this is a cross post. This should be here but it is also in the 100% pure Java forum. It won't happen again.
    Now...
    Why doesn't this work? How do I use the method add(int a, int b)?
    ERROR - "Can't make static reference to method int add(int, int) in testClass"
    interface testInterface{   
        static String sString = "TESTING";   
        public int add(int a, int b);
    class testClass implements testInterface{
        public int add(int a, int b){
            return a+b;      
        public static void main(String argv[]){
            int sum = add(3,4);    // here's the error
            System.out.println("test");
            System.out.println( sum );   
    }Again, I apologize for the cross post.

    hi,
    this seems to be pretty easy, isn't it?
    Oh c'mon! You try to invoke a non-static method from within a static method. Solution: Create a specific instance of class testClass:
    testClass test=new testClass();
    test.add(3,4);best regards, Michael

  • Error: Cannot make a static reference to the non-static method

    Below is a java code. I attempt to call method1 and method2 and I got this error:
    Cannot make a static reference to the non-static method but If I add the keyword static in front of my method1 and method2 then I would be freely call the methods with no error!
    Anyone has an idea about such error? and I wrote all code in the same one file.
    public class Lab1 {
         public static void main(String[] args) {
              method1(); //error
         public  void method1 ()
         public  void method2 ()
    }

    See the Search Forums at the left of the screen?
    If you had searched with "Cannot make a static reference to the non-static method"
    http://search.sun.com/search/onesearch/index.jsp?qt=Cannot+make+a+static+reference+to+the+non-static+method+&rfsubcat=siteforumid%3Ajava54&col=developer-forums
    you would have the answer. Almost every question you will ask has already been asked and answered.

  • How do I use a static reference to keep a VI in memory but then call it in parallel?

    Hello all,
    I have a MainVI and I want to call from it a SubVI in parallel so that I can have both windows open and responsive at the same time.  The SubVI may be closed and reopened any number of times, but only one in existance at a time.  I know how to do this using Open VI Reference, providing a relative path to my SubVI, checking its state to see if its already running, and if so bring the window to the front (using Front Panel: Open method with True/Standard inputs), and if not run it using the Invoke:Run method (and optionally opening its front panel programmatically).  This method was working fine.
    Now I have added functional global variables in my SubVI, and I want to keep them in memory inbetween opening the SubVI window.  I can do this by putting a copy of the functional global in my MainVI, even though I don't use it there for anything.  This works fine.
    By accident, I have come across a reference to a Static VI Reference, which sounded like a vast improvement to my methodology, for the following reasons:
    1) Keeps SubVI in memory all the time, eliminating the need to put the functional global in MainVI when it is not used there.
    2) Tells LabVIEW to include SubVI when I build my executable, rather than me having to specifically mark it as Always Include in the build specification.
    3) Eliminates the need to keep the path and SubVI name updated in a string constant in my code, in order to use the Open VI Reference.
    However, trying to implement this solution, I have run into the problem that once you put a strictly-typed static VI reference (strict typing is required to keep it in memory) onto the block diagram, that VI is reserved for execution.  That means I cannot run it using the Invoke:Run method.  I haven't tried just putting it on the diagram directly as a subVI because I need it to run in parallel to the MainVI.  I have searched through these forums extensively, and although there are several references to a static VI reference, none of them say explicitly how to actually run the darn thing!  :-P
    I very much appreciate any insight into my problem.  If I have to go back to the old way it will work fine, but I really like the seeming elegance of this solution.  I hope that it is technically feasible and I'm not misunderstanding something.
    Thank you for your help,
    -Joe
    Solved!
    Go to Solution.

    > If I understand you correctly, they can only really be used for re-entrant VIs. 
    No, a static VI reference can be used anywhere a regular VI reference (property nodes etc.) The reason for the hoop-jumping above is that we are really opening a reference to a CLONE (copy) of the VI identified by the static VI reference.
    > Okay, I tried it, and got the code shown below... Any idea why it isn't working?
    The VI you want to clone can't be on the diagram as a "normal" subVI. When you run your application you should be able to open that VI and see it just sitting there with a run arrow waiting to run. See attached example (LV2009SP1).
    "share clones" vs "preallocate" has to do with whether you want each clone to preserve state (such as in an uninitialized shift register). Generally you use share clones. Occasionally it is useful to have multiple copies on a diagram that each remember some data, like "timestamp of last execution" in a shift register.
    Other VIs in your spawned process don't have to be re-entrant unless they are functions that "wait forever". All the built-in G functions are re-entrant. It's pretty common to use a queue to feed data to a spawned process.
    Spawning a process is more difficult than just running two parallel loops. It's useful because once you've made 1 copy, you can make 50. If you just want to do two things (vs n things) at once, I would just use two loops.
    Attachments:
    SpawnProcess.zip ‏20 KB

  • In Numbers, how can I make a cell reference a constant in a formula?

    This is a basic question, but I am not sure of the answer. I am trying to calculate a previous SUM that I have by a column. But when I calculate it, it keeps looking for data in the cells after the SUM that I already have.
    In other words, how can I get a constant cells value into my equation?
    Any help would be great!
    (In excel, I could do it just by placing $ around my cell field. Like H23 would be $H23$. THanks!)

    JJ,
    Numbers works exactly like Excel in this regard. To change H23 from a reference that will change if the formula is moved to a fixed cell reference, make it $H$23.
    Regards,
    Jerry

  • How do I make a cell reference the condition in a COUNTIF statement?

    I have a formula:
    =COUNTIF(Funds Under Management by Client :: D2:D91,">3.0")
    However, I want to replace the condition '3.0' with a reference to another cell eg B2 so that I can play around with different values and have them immediately reflected in the COUNTIF total. Problem is, I can't find the right syntax to achieve this. I want the formula to actually look something like this:
    =COUNTIF(Funds Under Management by Client :: D2:D91,">B2")
    Is this possible, and if so, how do I do it? Making the formula refer to a cell saves me from having to manually change 90 odd cells in the spreadsheet every time I want to vary the criteria.
    TIA
    Message was edited by: Basilisk

    Fantastic! That worked great. Many thanks for your help. Simple when you know how!
    Message was edited by: Basilisk

  • How Can I make a Frame AlwaysOnTop using Native Methods

    Hi Have Developed The Sample Application for Always On Top that is compiled successfully even executed without any exception, but the frame is not always On Top As I required.
    I m m using
    -Windows XP 2004
    -J2SDK-1.4.2
    -Microsoft Visual C++ 6.0
    The following is the code
    and all files mentioned right after the code:
    1- MyFrame.java
    import java.awt.*;
    import javax.swing.*;
    public class MyFrame extends JFrame{
         static { System.loadLibrary("MyFrame"); }
         public MyFrame() {
              super();
         public void setAlwaysOnTop(boolean b) {
              int hwnd = getNativeWindowHandle(this);
              setAlwaysOnTop(hwnd, b);
         private native int getNativeWindowHandle(Window window);
         private native void setAlwaysOnTop(int hwnd, boolean flag);
    2- AtTopTestFrame.java
    public class AtTopTestFrame {
         public static void main(String s[])
              MyFrame frm = new MyFrame();
              frm.setSize(300,300);
              frm.show();
              frm.setAlwaysOnTop(true);
    3- MyFrame.cpp
    #include <jni.h>
    #include <jawt.h>
    #include <afxwin.h>
    #include <windows.h>
    #include "MyFrame.h"
    #include "jawt_md.h"
    JNIEXPORT jint JNICALL
    Java_MyFrame_getNativeWindowHandle(JNIEnv *env, jobject jobj, jobject window)
         JAWT awt;
         awt.version = JAWT_VERSION_1_4;
         jboolean result = JAWT_GetAWT(env, &awt);
         if (result == JNI_FALSE)
              return 105;
         JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, window);
         if (ds == 0)
              return 106;
         jint lock = ds->Lock(ds);
         if ((lock & JAWT_LOCK_ERROR) != 0)
              return 107;
         JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
         if (dsi == 0)
              return 108;
         JAWT_Win32DrawingSurfaceInfo* dsiwin = (JAWT_Win32DrawingSurfaceInfo*) dsi->platformInfo;
         jint ret = reinterpret_cast<jint>(dsiwin->hwnd);
         ds->FreeDrawingSurfaceInfo(dsi);
         ds->Unlock(ds);
         awt.FreeDrawingSurface(ds);
         return ret;
    JNIEXPORT void JNICALL
    Java_MyFrame_setAlwaysOnTop(JNIEnv *env, jobject jobj, jint hwnd, jboolean flag)
         if (flag)
              SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
         else
              SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
    Steps I performed For compilation
    1-MyFrame.class (with command "javac MyFrame.java")
    2-MyFrame.h (with command "javah MyFrame" )
    3-MyFrame.obj(with command "cl -IE:\j2sdk1.4.2_03\include -IE:\j2sdk1.4.2_03\include\win32 /c -LD -IMyFrame.h MyFrame.cpp")
    4-MyFrame.dll(with command "link /DLL MyFrame.obj E:\j2sdk1.4.2_03\lib\jawt.lib")
    5-AtTopTestFrame.class (with command "javac AtTopTestFrame.java")
    6-Execute AtTopTestFrame.class (with command "java AtTopTestFrame")
    After the steps performed on the above three files. I got a frame appeared as usual but that is not AlwaysOnTop as I required.
    I m again telling that I m using
    -Windows XP 2004
    -J2SDK-1.4.2
    -Microsoft Visual C++ 6.0
    Can any one take a review of this code and please help me. It is most required for my assignment to be completed. I just required my frame AlwaysOnTop.
    Thanks
    Khurram.

    HI guys
    Can any one help me in above problem
    Thanks
    Khurram

  • How do I make my error source look like standard LabVIEW codes?

    I have my error codes stored in an *-error.txt file.  I'd like to format the error source so it looks like a typical LV error source.  I've tried using an error code to error cluster and then either a simple or general error handler and I only get the error code, but the message has all the stuff I need.  I don't want to wire the message to the source, because that's not how LV error codes are normally displayed.  Am I making sense?  LV 7.1.
    Bill
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

    Yeah, I understand.  I have a vague question and I have to have help from you guys to even formulate it correctly.  Thanks, I will get back here soon!
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • How to get caller object reference from a method

    Hi,
    I am working a already existing Java Swing project, now I got a problem, in a method I need to get the caller object reference otherwise, I can't succeed this operation. So please tell me a way how to get the caller object reference from a method. that method would be static or regular method anything will do for me.
    Edited by: navaneeth.j on Jan 29, 2010 11:20 PM

    navaneeth.j wrote:
    Actually my doubt is, I have a method "addition" method, which is using by many classes so my requirement is in the addition method I want to write a code snippet which will identify and get the the caller object. Actually I tried Reflection.getcallerclass but there I am getting "CLASS" object not the actual object reference, but I want object reference.
    Actually we have a huge project which is writen plain JAVA, so in this project the authors written the Database connection package for single database transaction. so now we are using this project source code for JSF application in this web application the DB package has serve based on the dynamic db connection parameters, so if we want to change this package fully means need to solve the dependency problem in hundreds of classes, so my point is if I can access the caller object in the DB package when ever it gets called by any class from any where of the project. So actually I liked Reflection.getcallerclass, the way of implementation perfectly works for me but it is not giving caller object reference, if something gives the caller object then I can get the DB connection parameters then there is no need to pass the parameters in the hierarchy.You can add a parameter (of type Object) to your addition() method
    and everywhere you call the addition() method also pass this (which from the POW of the addition() method will be a reference to the calling class instance).
    There may be alternative solutions
    but none that require less effort.

  • STATIC REFERENCE

    THE CODE IS ATTACHED. I NEED TO SOLVE THE ERROS.
    THIS IS THE ERRORS AFTER COMPILE
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:47: Can't make static reference to method void setLayout(java.awt.LayoutManager) in class java.awt.Container.
                        setLayout(new FlowLayout());
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:48: Can't make static reference to method void setBackground(java.awt.Color) in class java.awt.Component.
                        setBackground(Color.green);
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:53: Can't make static reference to method java.awt.Component add(java.awt.Component) in class java.awt.Container.
                        add(l);
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:58: Can't make static reference to method java.awt.Component add(java.awt.Component) in class java.awt.Container.
                        add(name);
                        ^
    C:\My Documents\Java\Assignment\Assign3\PwdClient.java:61: Can't make a static reference to nonstatic variable tf_name in class PwdClient.
                        tf_name = new TextField(20);
                        ^
    5 errors
    //HERE IS THE CODE
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    class PwdClient extends Frame
         private TextField tf_name;
         private TextField tf_password;
         private String input_str_name;
         private String input_str_password;
         private String str_to_pass;
         //private String str;
         //private String str_name;
         //private String str_password;
         //private Button button1;
         private final static int buffsize = 512;
         public static void main(String args[])
              try
                        String server = args[0];
                        int port = Integer.parseInt(args[1]);
                        //create socket
                        Socket s = new Socket(server, port);
                        //readresult from server
                        InputStream is = s.getInputStream();
                        DataInputStream dis = new DataInputStream(is);
                        OutputStream os = s.getOutputStream();
                        DataOutputStream dos = new DataOutputStream(os);
                        InputStreamReader isr = new InputStreamReader(System.in);
                        BufferedReader br = new BufferedReader(isr);
                        //Frame frm = new Frame( "Client Server" );
                        setLayout(new FlowLayout());
                        setBackground(Color.green);
                        String str = "Enter Name and Password:";
                        Label l= new Label( str, Label.CENTER);
                        l.setBackground(Color.red);
                        add(l);
                        String str_name = "Name:";
                        Label name = new Label( str_name, Label.CENTER);
                        name.setBackground(Color.red);
                        add(name);
                        //Name textfield User input for name
                        tf_name = new TextField(20);
                        add(tf_name);
                        String str_password = "Password:";
                        Label password = new Label( str_password, Label.CENTER);
                        password.setBackground(Color.red);
                        add(password);
                        //Password Textfield (user input for password)
                        tf_password = new TextField(20);
                        tf_password.setEchoChar('*');
                        add(tf_password);
                        Button Button1 = new Button("Submit");
                        add(Button1);
                        Button1.addActionListener( new ActionListener()
                             public void actionPerformed(ActionEvent ae)
                                  input_str_name = tf_name.getText();
                                  tf_name.setText(new String(""));
                                  input_str_password = tf_password.getText();
                                  tf_password.setText(new String(""));
                                  str_to_pass = input_str_name+"/"+input_str_password;
                                  dos.writeBytes(str_to_pass);
                                  String received_from_server = brr.readLine();
                                  l.setText(received_from_server, Label.CENTER);
                        frm.setSize( 300, 200 );
                        frm.show();
                        frm.addWindowListener( new WindowAdapter()
                             public void windowClosing(WindowEvent e)
                             { System.exit(0);}
              }//closes the try
              catch(Exception e){}

    Put the code you have in static main in a constructor, or make an instance of PwdClient in main that you can call those methods on. You can't call non-static methods directly from a static method (main). You need to instantiate the class.
    public class PwdClient extends JFrame {
      public PwdClient() {
        // the code from your main method
      public static void main(String[] args) {
        new PwdClient(); // makes a new instance of PwdClient
    }

  • How can we make the save button active in standard toolbar in outout of alv

    Hi experts ,
    I am using factory method to print alv with oops .
    Cancel , Exit and Back button are active by default in Standard tool bar  in output of Report , But Save button is not active , How can i make that save button active .
    Also Pls tell me how i can make editable to the cell in output , 
    My Code is like this :
    cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = ispfli ).
      gr_functions = gr_table->get_functions( ).
      gr_functions->set_all( abap_true ).
      gr_display = gr_table->get_display_settings( ).
      gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
      gr_display->set_list_header( 'This is the heading' ).
      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'CITYTO' ).
      gr_column->set_long_text( 'This is long text' ).
      gr_column->set_medium_text( 'This is med text' ).
      gr_column->set_short_text( 'This is sh' ).
      gr_column ?= gr_columns->get_column( 'CITYFROM' ).
      color-col = '6'.
      color-int = '1'.
      color-inv = '0'.
      gr_column->set_color( color ).
      gr_sorts = gr_table->get_sorts( ).
    *gr_sorts->add_sort( 'CITYTO' ).
      gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
      gr_agg = gr_table->get_aggregations( ).
      gr_agg->add_aggregation( 'DISTANCE' ).
      gr_filter = gr_table->get_filters( ).
      gr_filter->add_filter( columnname = 'CARRID' low = 'DL' ).
      gr_layout = gr_table->get_layout( ).
      gr_layout->set_key( key ).
      key-report = sy-repid.
      gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
      gr_table->display( ).
    Rgds,
    Premraj

    Hi,
    1)you need to give the function code to that save in the Function Keys of that screen from the GUI Status.
    2) while filling the field catalog of that field you need to put the        
    wa_fieldcat_edit-edit = c_x.
    i.e use the edit and append to that field catalog internal table.
    for more infomation you can refer to below links:
    problem with alv edit and save
    *Edit* and *Save*  for the selected records in ALV
    solves your problem
    Thanks!!

  • How do i make an rollback?

    Hi,
    how do i make an rollback? I have the following code but it's not making the rollback correctly. First query runs fine
    and second one results in error but it not rollback the first query, the update, as i want. Any help? Thanks.
    java.sql.Statement stmt = null;
    java.sql.ResultSet rs = null;
    java.sql.Connection conn = null;
    boolean error = false;
    String driverBD="COM.ibm.db2.jdbc.net.DB2Driver";
    String nomeBD="<BD name>";
    String userBD="<BD user>";
    String pwdBD="<BD pwd>";
    try {
         Class.forName(driverBD);
         conn = java.sql.DriverManager.getConnection(nomeBD, userBD, pwdBD);
    catch(NullPointerException e) {
         System.out.println("Error connecting to BD: " + e);
         error = true;
    catch(ClassNotFoundException e)
         System.out.println("Error connecting to BD: " + e);
         error = true;
    catch(java.sql.SQLException e)
         System.out.println("Error in connection: " + e);
         error = true;
    if (!error) {
         try {
              String query = "UPDATE TEST.TBTEST SET EVENTREAD=null WHERE COD=438";
              stmt = conn.createStatement();
              stmt.executeQuery(query);
              query = "UPDATE TEST.TBTEST SET EVENTREAD=NULL WHERE COD=";
              stmt = conn.createStatement();
              stmt.executeQuery(query);
         } catch (Exception e) {
              System.out.println("Error in query: " + e);
              conn.rollback();
              //conn.commit();
    Thanks once again,
    Nuno Almeida

    example:
    http://javaalmanac.com/egs/java.sql/Commit.html

  • How do I make a 3D shape or mesh transparent?

    I have a photo of a bottle I need to mock up with a label I designed. Warping placed graphics isn't doing the trick, it looks wonky. I made a 3D mesh and loaded my label as a texture onto it so that it matches the shape and angle of the bottle. Problem is I don't want the gray mesh shape to be visible, I just want the label itself. I can't for the life of me figure out how to make the shape the label is wrapped around transparent while leaving the label visible. I'm using Photoshop CS4 and have bee looking online for answers but can't find any. Does anyone know how I can make the shape invisible or another method that warps the label in 3D space? Sure am missing the Render > 3D Transform option right about now…

    You might try setting the opacity to zero for the other materials besides the label.
    There is also a wine bottle preset under 3d-New Shape From Layer-Wine Bottle that might work better.

  • Static reference; how am I instantiating this incorrectly?

    Hi, all:
    I'm getting a static reference error, but I don't know how to fix it. I'm trying to generate a list of objects, and I can't tell where the problem is located. I've chopped all the irrelevant stuff out of this class so you can see what's going on:
    public class VonNeumannGridNet {
         public int nCols = -1;
         public int nNodes;
         public int nRows = -1;
         public int radius = -1;
         public ArrayList <Node> nodeList;
         public Class <Node> nodeClass;
         public Class <Edge> edgeClass;
         public VonNeumannGridNet ( Class<Node> node, Class <Edge> edge, int cols, int rows, int connectRadius) {
              nodeClass = node;
              edgeClass = edge;
              nCols = cols;
              nRows = rows;
              nNodes = nCols * nRows;
              radius = connectRadius;
         public ArrayList<Node> makeVonNeumannGridNet(Class<Node> node, Class<Edge> edge,
                   int cols, int rows, int connectRadius) throws IllegalAccessException, InstantiationException     {
              return nodeList;
         public static List <Node> makeVonNeumannGridNet(int cols, int rows, int connectRadius,
                   double rewireProb, Class <Node> node, Class <Edge> edge) {
              ArrayList <Node> list = makeVonNeumannGridNet(node, edge, cols, rows, connectRadius); //ERROR HERE
              ArrayList <Node> network = new ArrayList <Node> (NetUtilities.randomRewireSymmetric(list, rewireProb));
              return network;
    public Class <Node> getNodeClass() {     return nodeClass;}
    public void setNodeClass(Class <Node> node)     {nodeClass = node;}
    public Class <Edge> getEdgeClass()     { return edgeClass;}
    public void setEdgeClass(Class <Edge> edge) {edgeClass = edge;}
    }The error happens when I try to "makeVonNeumannGridNet"; how is that a static reference?

    Geesh what a worthless discussion.
    After all, the cause of your problem is that you're trying to access an instance method from within a static (non-instance!) method. The possible solutions might be obvious:
    1) make both methods non-static.
    2) make both methods static.
    3) make the calling method non-static and make the method-to-be-called static.
    4) instantiate the class having the instance method and invoke that method using the reference.
    Read a good Java book/tutorial and learn about static vs. non-static. Don't use them randomly, but use them when the design and behaviour require.

  • Can't make static reference to method while it is static

    Hello, can somebody please help me with my problem. I created a jsp page wich includes a .java file I wrote. In this JSP I called a method in the class I created. It worked but when I made the method static and adjusted the calling of the method it started to complain while i didnt make an instance of the class. the error is:Can't make static reference to method
    here is the code for the class and jsp:
    public class PhoneCheckHelper {
    public static String checkPhoneNumber(String phoneNumber) {
    String newPhoneNumber ="";
    for(int i=0; i<phoneNumber.length(); i++) {
    char ch = phoneNumber.charAt(i);
    if(Character.isDigit(ch)) {
    newPhoneNumber += String.valueOf(ch);
    return newPhoneNumber;
    <html>
    <head>
    <title>phonecheck_handler jsp pagina</title>
    <%@page import="java.util.*,com.twofoldmedia.text.*, java.lang.*" %>
    </head>
    <body>
    <input type="text" value="<%= PhoneCheckHelper.checkPhoneNumber(request.getParameter("phonenumberfield")) %>">
    </body>
    </html>

    Go over to the "New to Java" forum where that message is frequently explained. Do a search if you don't see it in the first page of posts.

Maybe you are looking for

  • Apex 4.1 different font text in Reports Region and Interactive reporting

    Hi everybody, In my APEX 4.1 page, I have two regions using the same ''Reports region" Template but font text are different. Why The first region is an interactive reporting. The second it's a report. I know that each one has his own data for sure bu

  • Where the standard smart forms stored in sap

    hi this is kishore kumar i am new to smart forms please tell me any body in which table table standard smart froms r stored for example scripts r stored in  TNAPR TABLES so in which table smart forms r stored please tell me or how to use standard sma

  • Firefox wont load/browse unless keyboard/mouse is active

    Firefox last automatically updated for me the other day. Since then when I open firefox, I can click on the desktop icon or the quick launch, in either case it seems like firefox never opens unless I click with my mouse or hit a key(s) on the keyboar

  • MIRO: Multiple plants exist in the same invoice

    Hi, We are posting the MIRO against a Purchase Order. There are two line items in a PO. Both line items have different plants. We have posted separate Goods Receipts for both the line items. Now, at the time of posting MIRO system is giving an error

  • Simple state machine Where to begin?

    Hello Got a question that is simple for the experienced people here I guess. But don't know where to start..... Here is what I want to try to do: I have got a lot of inputs, to keep the question simple I have only drawn a few of them but eventually t