What's new

Closed Java programs

Status
Not open for further replies.

PHC-Janna

Honorary Poster
Joined
Nov 27, 2016
Posts
356
Reaction
287
Points
195
Age
29
Java programming: Java program code consists of instructions which will be executed on your computer system to perform a task as an example say arrange given integers in ascending order. This page contains examples for beginners to understand how to use java programming to write simple Java programs. These codes demonstrate how to get input from user, working with loops, strings and arrays. Programs are provided with output (image file) and you can also download class file and execute it directly without compiling the source file.

Compiling and executing java programs
Java programming software: To compile and run Java program code you need to download You do not have permission to view the full content of this post. Log in or register now. (Java Development Kit).

To compile type: javac file_name.java where file_name is name of file containing java source code.
Javac is the Java compiler which converts java code into bytecode.

To run type: java main_method_class where main_method_class is the name of class which defines main method.

Learn Java through books
If you are just starting to learn Java then it is recommended to buy You do not have permission to view the full content of this post. Log in or register now.
ir
. A Java book will help you to easy learn basic concepts and will act as a reference for all time.

Java programming examples
Example 1: Display message on computer screen.

class First {
public static void main(String[] arguments) {
System.out.println("Let's do something using Java technology.");
}
}
This is similar to hello world java program. You do not have permission to view the full content of this post. Log in or register now. class file.

Output of program:
first-java-program


Example 2: Print integers

class Integers {
public static void main(String[] arguments) {
int c; //declaring a variable

/* Using for loop to repeat instruction execution */

for (c = 1; c <= 10; c++) {
System.out.println(c);
}
}
}
Output:
integers-java-program


If else control instructions:

class Condition {
public static void main(String[] args) {
boolean learning = true;

if (learning) {
System.out.println("Java programmer");
}
else {
System.out.println("What are you doing here?");
}
}
}
Output:
if-else-java-program


Command line arguments:

class Arguments {
public static void main(String[] args) {
for (String t: args) {
System.out.println(t);
}
}
}
command-line-arguments-java


Java programming language
Below is the list of java programs which will help you in learn java programming language.

Java Development IDE
As your programming experience grows in Java you may be developing your own project or software, using a simple text editor is not recommended. Following are two popular and open source IDE's:

Using IDE helps you a lot while coding as they offer many useful features such as you can create GUI in Netbeans without writing any code, Netbeans will show you any compilation error before you compile your code and it can also show hints on how to fix that.

Java programming tutorial
Java technology has changed our life as most of devices we use today includes java that's why to learn java programming is a good thing. Java was developed by Sun Microsystems but now owned by Oracle. Here is a quick java tutorial for beginners, Java is an object oriented computer programming like C++, if you already know C++ or any other object oriented language then it will be easier for you to learn java. Java program consists of classes which contain methods, you can't write a method outside a class. Objects are instances of classes. Consider the following code:

class ProgrammingLanguage {
//attributes
String language_name;
String language_type;

//constructor
ProgrammingLanguage(String n, String t) {
language_name = n;
language_type = t;
}

//main method
public static void main(String[] args) {
//creating objects of class
ProgrammingLanguage C = new ProgrammingLanguage("C", "Procedural");
ProgrammingLanguage Cpp = new ProgrammingLanguage("C++", "Object oriented");

//calling method
C.display();
Cpp.display();
}

//method (function in C++ programming)
void display() {
System.out.println("Language name:"+language_name);
System.out.println("Language type:"+language_type);
}
}
There is a ProgrammingLanguage class and all programming languages will be instances of this class. We have considered only two attributes language name and type, we can create instances of class using new keyword. There is a constructor method which is invoked when an object of class is created we use it to name the programming language and its type. Main method is a must and acts as starting point of program, display method is used to print information about programming language object. Class names in java begin with a capital letter and if there are more words in class then their first letter will also be capital, for example MyJavaClass is a class name and for methods (functions in C or C++) first letter is small and other words first letter is capital as an example myJava is method name. These are only conventions, but are useful in distinguishing classes from methods. Java has a very rich API to build desktop and web applications.

PS: If you don't know the meaning's of java program languages, just reply to this thread or PM me.

Press Like And Thanks !
 
TS, ano po yung inheritance sa java?

Kung baga . MANA mo yan galing sa lolo at lola mo ;)

Inherting from another classes methods
Kung anong method nandun sa isang class pwede mo gamitin from within your class

Class A has Print method

Class B is inherting from class A

so any public method from class a meron ka din. No need to create print method in class B.
 
Kung baga . MANA mo yan galing sa lolo at lola mo ;)

Inherting from another classes methods
Kung anong method nandun sa isang class pwede mo gamitin from within your class

Class A has Print method

Class B is inherting from class A

so any public method from class a meron ka din. No need to create print method in class B.
Kailangan pa ba ng keyword para mainherit yung mga method o default property na iyon ng mga class?
 
Swing po. Pwede mag drag n drop sa Netbeans. Madugo kasi mag manual input ng margins/sizes sa notepad lang, haha
 
Status
Not open for further replies.
Back
Top