On Jan 10, 2005, at 22:00, Liam Clarke wrote:

Hehe, I'm not up to collections yet... working through Learning Java
by O'Reilly.

If you already know a bit about OOP, I would recommend that you read bruce Eckel's "Thinking in Java". An excellent book, freely available on-line (do a quick Google search), and it taught me in 1 week all I needed to understand my courses (which dealt with OO analysis and design, Swing GUIs and some ore advanced topics).
A good follow-up to that would be McMillan & Wiggleswrorth's "Java Programming - Advanced Topics", through which I'm currently reading. It has some really good stuff, including things about XML parsing with SAX and DOM...
I may actually be about to understand how to use SAX and DOM, w00t! (*prepares a bottle of Champagne*)


(Why can't a non-static
method comparison be called from a static reference? What does that
mean anyway?

Er... What was your code like? (before and after correcting the error)


it was (off top of head here)

public class dude

{
public static void main(String [] args) {

System.out.print(args[0]);
if (doComp(args[0]));
    {
    System.out.println(" is true");
    }
else
    {
    System.out.println(" is false");
  }

private boolean doComp(String x) {
   int j = new int(x);           #I can't quite remember how I did
this precisely.

   if (j==1)
      {
      return True;
      }
   else
      {
       return False;
       }
     }

}

Okay, I understand the problem, and it's quite logical once you know the reason.


Basically, static methods and variables are class methods/variables. That is, they're bound to the class as a whole and not to any instance of it (in fact, they can be used without instanciating the class at all).
Non-static members are instance members. They are bound to and act upon specific instances of the class. Thus, you can't use them before instanciating the class first.


        So, if I have a class called Foo which has the following:
public static void bar()
public void baz()

I can use bar() straight away, by calling Foo.bar().
But if I want to use baz(), I first have to instanciate Foo, with something like Foo blah = new Foo(); and then call blah.baz(), which will then return whatever baz() computes based on blah's state.



I guess that if you want your program to be wholly procedural, you need to make all your functions (methods) static, then.
But if you're doing that, you're misusing Java. OO programming is where it shines.


I have no startup lag really.

I stand corrected. But my other point is still valid -- see the Great Language Shootout Benchmarks for "better" (and customizable) language benchmarks.


*sigh* I have no net at home at moment, which is very frustrating when
I want to d/l documentation & editors. For the mo, it's all Notepad.
Ick.

I feel your pain. Coding in any language is a chore with Notepad -- it comes down to whichever language requires the least (keyboard) typing being the least unpleasant to use. And Java, unlike Python, requires a lot of typing.



-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?"


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to