Java Reference
In-Depth Information
<html>
<head>
<title> A Simple Program </title>
<SCRIPT language="VBSCRIPT"
src="http://java.sun.com/products/plugin/1.4/autodl/autodownload.vbs">
</SCRIPT>
</head>
<body>
<hr/>
<applet code = "MyFirstApplet.class" width = 300 height = 200 >
</applet>
<hr/>
</body>
</html>
This makes use of a script that is downloaded from the Sun Java web site. If you want, you can
download a copy of the script to your local machine and run it from there. In this case you will need to
amend the URL for the src attribute in the <SCRIPT> to reflect where you have stored the .vbs file.
Object-Oriented Programming in Java
As we said at the beginning of this chapter, Java is an object-oriented language. When you use a
programming language that is not object oriented, you must express the solution to every problem
essentially in terms of numbers and characters - the basic kinds of data that you can manipulate in the
language. In an object-oriented language like Java, things are different. Of course, you still have
numbers and characters to work with - these are referred to as the basic data types - but you can define
other kinds of entities that are relevant to your particular problem. You solve your problem in terms of
the entities or objects that occur in the context of the problem. This not only affects how a program is
structured, but also the terms in which the solution to your problem is expressed. If your problem
concerns baseball players, your Java program is likely to have BaseballPlayer objects in it; if you
are producing a program dealing with fruit production in California, it may well have objects that are
Oranges in it. Apart from seeming to be inherently sensible, object-oriented programs are usually
easier to understand.
In Java almost everything is an object. If you haven't delved into object-oriented programming before,
or maybe because you have, you may feel this is a bit daunting. But fear not. Objects in Java are
particularly easy. So easy, in fact, that we are going to start out by understanding some of the ideas
behind Java objects right now. In that way you will be on the right track from the outset.
This doesn't mean we are going to jump in with all the precise nitty-gritty of Java that you need for
describing and using objects. We are just going to get the concepts straight at this point. We will do this
by taking a stroll through the basics using the odd bit of Java code where it helps the ideas along. All the
code that we use here will be fully explained in later chapters. Concentrate on understanding the notion
of objects first. Then we can ease into the specific practical details as we go along.
Search WWH ::




Custom Search