Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-20-2007, 05:48 PM
Echilon's Avatar
Member
 
Join Date: Dec 2007
Location: England
Posts: 6
Echilon is on a distinguished road
Send a message via ICQ to Echilon
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?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-20-2007, 06:59 PM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 123
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
Can you post the code that actually calls the method?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-21-2007, 03:31 PM
Echilon's Avatar
Member
 
Join Date: Dec 2007
Location: England
Posts: 6
Echilon is on a distinguished road
Send a message via ICQ to Echilon
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].
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Static function to get current working directory Java Tip Java Tips 1 06-23-2008 04:13 AM
Why methods in an interface cannot be static? cbalu Advanced Java 2 12-12-2007 09:57 PM
Mocking static methods of class Kat New To Java 3 11-08-2007 02:24 AM
Static methods Java Tip Java Tips 0 11-04-2007 07:56 PM
significance of static variables and methods imran_khan New To Java 4 08-02-2007 11:52 AM


All times are GMT +3. The time now is 01:36 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org