Advertise Here

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Marsada

Pages: [1]
1
Java / [JavaTutorial] Packaging
« on: February 09, 2009, 08:35:49 pm »
[JavaTutorial] Packaging

Requirements: Folders(Not many)

Benifits:
*You will be able to acess java files a lot quicker than before.
*Your Java Project will look a lot cleaner than before.
_________________________________________________________

The main code for packaging is package.

How to locate java files with packaging?
If your java file is located in the, lets say myfolder1, your package code will look like this(package myfolder1;)
_________________________________________________________

Example of a package:
Code: [Select]
package packaging.myfolder1;

/*packaging.myfolder1; is the same as (folder)packaging>(folder)myfolder1;
 *so basically your java file should be located in myfolder1
 */

public class HelloPackage {

public static void main(String[] args) {
System.out.println("Hello Package!");
}
}
_________________________________________________________

Running the packaged file.
You can compile and run, but thankfully i have provided you with the package of my own which you can download.
(It has a compiled java HelloPackage.java file with a successful runner.)
http://uppit.com/YI6LXP
http://uppit.com/MN7U1L
(Any of them are fine)

Thats about it for this tutorial.Thank you for visiting it.

/*
*Copyright Marsada(c)
*(c)2007-2009(c)
*/






2
Java / [JavaTutorial] Switch Statements
« on: February 09, 2009, 07:57:56 pm »
[JavaTutorial] Switch Statements

Make a new java file and name it MySwitch.java
Code: [Select]
//1.
public class MySwitch {
//2.
int switch1 = 1;
//3.
public void SwitchMethod(int switcho) {
//4.
switch(switcho) {
//5.
case 1:
//6.
System.out.println("Switch1=" +switch1);
//7.
break;
//8.
}
}
}


Line1:The name of the class.
Line2:Declaring and setting the values of the ints.
Line3:Creating the method for the statement.(int switcho) this provides the additional help.If you dont have a declared statement here, the switch will not respond.
Line4: The switch statement and the declared int.
Line5:Case 1.Switch statements always start with cases, the other way is if and else statements.
Line6:The execution or plan you want to set, for example if this method is runned, it will show System.out.println(Basically it will print in the declared int set, or whatever you put in there.Its just like a speech bar.
Line7:The break ends the case.And allows the next case to come.
Line8:Line 8 ends the method and the class.

Thats about it for this tutorial.Thank you for visiting it.

/*
*Copyright Marsada(c)
*(c)2007-2009(c)
*/

3
Great stuff man, thanks for your help! ;D

4
Java / [JavaTutorial]Creating a fundamental thread.
« on: February 09, 2009, 02:51:55 am »
Creating a fundamental thread

Requirements: General knowledge

Make a new class file and call it MyThread.java
Code: [Select]
public class MyThread {

public static void main(String[] agrs) throws InterruptedException {
String threadInfo[] = {
"Starting Thread 1",
"Starting Thread 2",
"Finished Thread"

};

for (int i = 0; i < threadInfo.length; i++) {
Thread.sleep(1000);
System.out.println(threadInfo[i]);
}
}
}

*Basically the you should all know the main method, this runs the project.
*throws InterruptedException enables the thread.
*StringthreadInfo is like a message tool.
* (for (int i = 0; i < threadInfo.length; i++) {) don't worry much about this code, this enables the String message with the thread.
*Thread.sleep(1000); The 1000 is the milliseconds, so this means right now it is set to (1)second.
*System.out.println(threadInfo); The System.out.println refers to as the command line print.It prints the message on to the command line in 1 second.

Thats about it for this tutorial.Thank you for visiting it.

/*
*Copyright Marsada(c)
*(c)2007-2009(c)
*/

Pages: [1]