-   Programming (
-   -   helper methods + System.out.println() not working. (caution- JAVA question) (

titanium_geek 05-20-2009 05:46 AM

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.


titanium_geek 05-20-2009 05:48 AM

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. :o :)


All times are GMT -5. The time now is 10:34 AM.