If you want to learn Java all you need is a text editor, tutorial and a lot of time.
For programming editor I recommend TextWrangler (it's free).
Later you can try something more sophisticated, like vim or emacs.
Or you can start with simpler, easier to learn and fun language, like Python.
There is a number of free online tutorials to learn Python:
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
Python has an interactive mode so you even do not need editor.
In Terminal type /usr/bin/python and you are redy to write your first
Python code:
mac:~/$ /usr/bin/python
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> # Python Hello world
... print "Hello, World"
Hello, World
>>> # loop:
... for i in range(5): print "Hello, World", i
...
Hello, World 0
Hello, World 1
Hello, World 2
Hello, World 3
Hello, World 4
>>>
Terminal is in /Applications/Utilities directory.
Following 4-line Python code that downloads a content of ww.yahoo.com root page, counts number of bytes, words and lines, and writes it into file - 'web.html':
>>> import urllib
>>> doc = urllib.urlopen("http://www.yahoo.com/").read()
>>> print len(doc), len (doc.split()), len (doc.split('\n'))
37230 2626 611
>>> open('web.html', 'w').write(doc)
# back to shell: count number of lines, words and bytes in web.html file
# and open the file in web browser:
mac:~/$ wc web.html
610 2626 37230 web.doc
mac:~/$ open web.html
Try to do the same in Java or Objective-C and you'll see the difference.
Good luck.