Results 1 to 3 of 3
  1. #1
    Echilon Guest

    Question Static methods - not working

    I'm having problems with a static method. Coming from PHP to Java, I miss the implode() function, so I wrote my own. I have a program with several classes. I need to use this method in all classes, and MainWindow is my central class. I've added the method to MainWindow with the following signature:
    public static String implode(String[] ary, String delim) {
    But when I try to call it from either of the other classes (it's used during file writing), using MainWindow.implode(), the program just doesn't do anything. I've even changed the file writing part to output to the console, but the method somehow stops after the call to implode() has been made.

    Is this the best way of adding an implode feature, or am I doing something wrong?

  2. #2
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Rep Power


    Can you post the code that actually calls the method?

  3. #3
    Echilon Guest


    Fields was the wrong variable to be checking it was null.

    For anyone else with a similar problem, I solved this by instead checking a HashMap using map.get(i) instead of fields[i]. :)

Similar Threads

  1. Static function to get current working directory
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 06-23-2008, 03:13 AM
  2. Why methods in an interface cannot be static?
    By cbalu in forum Advanced Java
    Replies: 2
    Last Post: 12-12-2007, 08:57 PM
  3. Mocking static methods of class
    By Kat in forum New To Java
    Replies: 3
    Last Post: 11-08-2007, 01:24 AM
  4. Static methods
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-04-2007, 06:56 PM
  5. significance of static variables and methods
    By imran_khan in forum New To Java
    Replies: 4
    Last Post: 08-02-2007, 10:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts