Programming

Introduction to Java : Building Your First Application part-3

Fadıl

Applet Tag by Example

Here is an example of the code we could use to place the Hello applet we created previously in a web page:

<APPLET WIDTH = "200" HEIGHT = "100"
           CODE = "Hello.class">
</APPLET>

Notice that we gave the applet a specific width and height. For an applet to appear, you must give it a specific width and height. If you don’t want an applet to display (such as when your applet creates a popup frame right away), you can give it a width and height of 0:

Introduction to Java : Building Your First Application part-2

Fadıl

Writing Applets

Applets are programs that run inside of a web page using the resources the web browser has to offer such as a Java Virtual Machine (JVM) and the default set of class libraries.

When you initially hit a web page with an incorporated Java applet, you usually see a gray box where the applet will show up and then slowly, the applet loads and appears in the space of the gray box.

PHP Function: Built-in Functions part 1

Fadıl

Array Fuctions –

array()
The array() function allows you to manually assign values to an array. Here is the syntax of the array() function:
$array_name = array(“val1”, “val2”, “val3”, …);

array_push()
The array_push() function allows you to add one or more elements to the end of an existing array. Its syntax is
array_push($array_name, “element 1”, “element 2”, …);

array_pop()
The array_pop() function allows you to take (pop) off the last element of existing array. Its syntax is
array_pop($array_name);

Introduction to Java : Building Your First Application part-1

Fadıl

Building an Application

Okay, so now let’s look at the rest of the Test class because the Test class is pretty special. The Test class is actually a very small Java Application that can be compiled and executed!

Here is the code again…

public class Test
  {
  public static void main(String[] args)
    {
    Announcer a = new Announcer();
    a.printAnnouncement();
    }
  }

You should already be comfortable with the definition of the class from the last section. You should also be familiar with the contents of the main() method since we just discussed it. But what is the main() method and why is there no constructor for Test?

Introduction to Java : Java Classes part-3

Fadıl

Defining a Class

So right after the “public” keyword, we see the “class” keyword. The class keyword is used to specify that the following statement block defines a class. The class can be used to instantiate an object that is defined by the class. In our example case, we are defining a class called “Announcer”.

By the way, a class is usually defined in a “.java” file that is compiled into bytecode by a compiler into a “.class” file. Typically, your .java and .class filenames will be equivalent to the class name. Thus, the Announcer class would be stored in a file called Announcer.java and be compiled into a file named Announcer.class.