Tuesday, 25 April 2017

Java for loops ~ foundjava

Java for loops is very similar to Java while loops in that it continues to process a block of code until a statement becomes false, and everything is defined in a single line.
Syntax:
for ( init; condition; increment )
{
   statement(s);
}
Read More »

Java do while loops ~ foundjava

Java do while loops is very similar to the java while loops, but it always executes the code block at least once and further more as long as the condition remains true.
Syntax:
do
{
   statement(s);

}while( condition );
Read More »

Java while loops ~ foundjava

Java while loops statement allows to repeatedly run the same block of code, until a condition is met.
Syntax:
While (condition)
{
   statement(s);
   Incrementation;
}
Read More »

Java switch Statements ~ foundjava

Java switch statement is used when you have multiple possibilities for the if statement.
Syntax:
switch(variable)
{
case 1:
   //execute your code
break;

case n:
   //execute your code
break;

default:
   //execute your code
break;
}
Read More »

Java else-if Statements ~ foundjava

Java else if is a like doing another if condition for a true or false value.
Syntax:
if(condition)
{
   //execute your code
}
else if(condition n)
{
   //execute your code
}
else
{
   //execute your code
}
Read More »

Java if-else Statements ~ foundjava

Java if else statements is used to execute some code, if a condition is true otherwise if condition is false, execute nothing, or execute some other code.
Syntax:
if(condition)
{
   //execute your code
}
else
{
   //execute your code
}
Read More »

Java if Statements ~ foundjava

Java if statements is used to execute some code, if a condition is true otherwise if condition is false, execute nothing.
Syntax:
if(condition)
{
    statement 1;
    statement 2;
    ...
}
Read More »

Thursday, 20 April 2017

Google APIs Client Library for Java announced, support OAuth 2.0 ~ foundjava

Google have announced the Java client library. With the version 1.5 release, the open source Google OAuth Client Library for Java is available in Beta, support for both OAuth 1.0a and OAuth 2.0. OAuth is an open standard for allowing a client application to securely gain access to a user’s private data stored on Google without ever asking for their password.
Read More »

MyFirstApplet, run applet in HTML page ~ foundjava

Create a file MyFirstApplet.java
?
1
2
3
4
5
6
7
8
9
10
import javax.swing.JApplet;
import java.awt.Graphics;
 
public class MyFirstApplet extends JApplet {
 
 public void paint(Graphics g) {
  g.drawString("Hello, Java-Buddy!", 50, 50);
 }
}

Read More »

HelloNetBeans: Create Java Desktop Application using NetBeans IDE ~ foundjava

- Start NetBeans IDE, click File -> New project... on top menu

- Select Categories of Java, and Projects of Java Desktop Application, and click Next.
New Project of Java Desktop Application
Read More »

NetBeans: Setting Events With the Connection Wizard ~ foundjava

Connection wizard can help to set events between two components within a form without having to write code manually.

Work on the exercise in last post "HelloNetBeans: Create Java Desktop Application using NetBeans IDE".

- Add a Button on Design Pane
- Right click on Button, Edit Text and enter "Click Me" as the text on the button.
Add a Button
Read More »

JDK 7 in a Nutshell ~ foundjava

Read More »

Implement Insertion Sort in Java ~ foundjava

Example of Insertion Sort using Java code:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
public class InsertionSort {
   
 public static void main(String[] args) {
  System.out.println("Hello, Java-Buddy!");
   
  MyData myData = new MyData();
  myData.show(); //Before sort
  myData.InsertionSort();
  myData.show(); //After sort
 }
Read More »