Java - Day 1

by Jesse 31. July 2008 04:14

The only way I ever learn how to use something is to use it outright and not by code examples.  Just doesn't work for me that way.  So I went out and bought "The Complete Reference - Java Seventh Edition" -- it was the only one that had a beginners section, without the "ok, this is a computer".   Just flipping randomly, chapter 11 covers multithreading ooo,  that'll be fun. Chapter 17 covers the Java.util : the collections framework...25 deals with images, fun.  29, "Intorduction to Swing".  Hmm. 

----- Consider items from here on down my notes. ------

I've kinda skimmed over chapter 1-7 so far and I'm on chapter 8.  So far, the syntax is almost 1:1.  Console.WriteLine("string") == System.out.println("string").  Another syntax difference is inheritance.  Inheritance in Java is called "extends".  For instance in C# ...

Public Class Class1{ }

Public Class Class2 : Class1 { }

Class2 would inherit Class1.  In Java, its similiar but different...

class Class1 { }

class Class2 extends Class1 { }

Not that bad, very easy so far.  Method overriding seems to be exactly the same, no difference there.  Same goes for making abstract classes and methods.  There is however a "final" keyword that inhibits overriding.  "final void SayHi();" would stop any inheriting class from overriding that method.

Chapter 9, Packages and interfaces -- Packages are like using includes/usings statements.  I -think- they're DLL style items like in .net, you add them, give a reference in your app, carry on.  Using statements are slightly different (more C/C++ style) -- import java.lang.*; for instance includes everything in the java.lang namespace and like C# you can use a fully qualified name if you wish, such as java.util.Date.  Interfaces are the same too...

interface CallBack {
     void callback(int param);
}

An interesting bit - "you should be careful not to use interfaces casually in performance-critical code" because of the overhead to create the objects.

Imagine that, there's a Try Catch Finally, exactly like in C#, even with the multiple Catch statements (say IOException and Exception).  Same with throws AND threading.  Wow this is becoming annoying, there's even a thread.Join (that means "wait for this thread to complete").

With that, I am stopping @ page 285.  I'm keeping my false sense of empowerment until tomorrow or ...sometime soon.

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Like the description says, at my core, I'm a scientist and engineer.  I came from humble beginnings on a 486DX2 Packard Hell playing doom2 on IPX to in a small time retail shop and got into hardware (ISO layers FTW!) and it was all downhill from there.  I'm infinitely curious about almost everything and always wanting to know.

Some of the stuff I'm currently into/researching...

Sitefinity

Ninject

Subsonic

Java

Currently working on ...
i did the hundred 
and some extra stuff

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's, their brother nor their dog's view in anyway.  At all.  Ever.

© Copyright 2007-2008