Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-20-2009, 06:46 AM   #1
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478

Rep: Reputation: 50
helper methods + System.out.println() not working. (caution- JAVA question)

A quick disclaimer before I begin my question- the last couple of times I've asked a Java question here I've been flamed. I realise that Java is the scum of the earth and there are much better languages to pick. I know. I'm constrained by my university. Just answer the question please, or stay quiet- please don't waste my time.

To the question: I have methods called by other methods and I want to check if they are actually doing their thing- quickly and easily, using System.out.println(). I want to know if there are issues with helper methods printing to the commandline/terminal or if there is something seriously wrong with my code. Since this is for homework I won't post my actual code, but the code to do with where the issue is.

public class MyClass 

   public MyClass() { //generic constructor. 

   public buildThis() { 
//take an input and build it into the data stucture. 

     int foo = usefulMethodWhichReturnsInt();
     System.out.println("This prints fine.");  //1

   public usefulMethodWhichReturnsInt() {
      System.out.println("Will this print?"); //2
      return 0; 

   public static void main(String args[]) {
      MyClass bar = new MyClass;
      System.out.println("This will also print."); //3
So yeah, will the usefulMethod be able to print something on the command line?

Thanks everyone in advance.

Old 05-20-2009, 06:48 AM   #2
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478

Original Poster
Rep: Reputation: 50
Ok, I added another trial method and it worked. (Grrr.) This means there are probably other bugs present in my code, sigh.

Fixed it. I think it's because my logic was really bad. Remembered to use if NOTs instead of ifs.


Last edited by titanium_geek; 05-20-2009 at 07:22 AM.


java, print

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
System.out.println("Hello, world."); rkirk Member Intro 1 04-16-2009 10:56 AM
difference between Java compare and compareTo methods kpachopoulos Programming 2 09-19-2004 05:08 AM
println question AMMullan Programming 2 04-18-2004 08:38 AM
java -- methods -- please help Laptop2250 Programming 2 12-13-2003 01:46 AM
system.out.println() not working in servlet, Tomcat Ethan Programming 7 07-24-2002 12:40 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:50 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration