John Delmark Aguilar
Would you like to react to this message? Create an account in a few clicks or log in to continue.
John Delmark Aguilar

Personal Forum
 
HomeSearchLatest imagesRegisterLog in

 

 Language Basics

Go down 
AuthorMessage
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Language Basics Empty
PostSubject: Language Basics   Language Basics Icon_minitimeSat Oct 20, 2012 4:28 pm

Language Basics

Create your first Java program

Let's start by compiling and running the following short sample program.
________________

/*
This is a simple Java program. Call this file "progname.java".
*/


public class progname {
// Your program begins with a call to main().
public static void main(String args[]) {
System.out.println("Java.");
}
}

Code:
/*
 This is a simple Java program. Call this file "progname.java".
 */

public class progname {
  // Your program begins with a call to main().
  public static void main(String args[]) {
    System.out.println("Java.");
      }
}

In Java, a source file is called a compilation unit. It is a text file that contains one or more class definitions. The Java compiler requires that a source file use the .java filename extension.

In Java, all code must reside inside a class. By convention, the name of the public class should match the its file name. And Java is case-sensitive.


For further explanation...

Arrow Open a text editor software, don't worry notepad will do.
Arrow Select all of the code then Paste the it in notepad.
Arrow Save it with a file name of progname.java (NOTE: progname.java is used as the file name because the class name must be the same with the file name)
Arrow Then compile the program. Follow it [You must be registered and logged in to see this link.]



Code:

/*
 This is a simple Java program. Call this file "progname.java".
 */

public class progname {
//the class name is progname, so save it as progname.java

  // Your program begins with a call to main().
  public static void main(String args[]) {
//The code here will be executed when you start the program, this will be the place in inserting syntax
    System.out.println("Java.");
//Displays an output - Java
      }
}
Back to top Go down
https://delmark.forumtl.com
 
Language Basics
Back to top 
Page 1 of 1
 Similar topics
-
» Fibonacci Assembly Language Code
» Factorial Assembly Language Code

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Java Programs :: Tutorials-
Jump to: