Thursday, December 31, 2009
Thursday, December 24, 2009
Saturday, December 19, 2009
Free Kubuntu 9.10 Book
http://www.esnips.com/web/KubuntuBook
You can download it by clicking on the Title (not the buy now button), and click the Download link. You may also buy it as a donation if you want. You may also want to download the Table Of Contents separately.
Thanks, and Merry Christmas!
Saturday, December 12, 2009
Create Your Own Christmas Cards Using Gimp
http://www.linuxplanet.com/linuxplanet/tutorials/6925/1/
Thursday, December 10, 2009
Python Programming For Beginners
http://www.themaemo.com/python-for-newbies/#How%20Python%20works
Wednesday, December 2, 2009
CD, DVD Burning Made Simple
http://www.ghacks.net/2009/11/29/simple-linux-disk-burning-with-brasero/
Tuesday, December 1, 2009
Jobs For The Jobless
http://www.kdenews.org/2009/11/29/kde-community-forums-announce-continuation-klassroom
Friday, November 27, 2009
Making Most Out of Ubuntu 9.10
http://www.johannes-eva.net/index.php?page=2009_10_useful_ubuntu_guide_karmic
Thursday, November 26, 2009
Thank You!
http://www.raiden.net/articles/giving_thanks_for_foss/
Tuesday, November 24, 2009
Create Database Using Openoffice.org Base Easily
http://www.linux.com/news/software/applications/176612-create-a-database-and-data-entry-form-in-openoffice-base
Monday, November 23, 2009
Ubuntu and Google Chrome OS
http://blogs.computerworld.com/15127/ubuntus_canonical_and_google_partner_to_create_chrome
Ubuntu 9.10 Tips
http://www.maximumpc.com/article/features/20_essential_tips_every_ubuntu_user_should_know?page=0%2C0
Saturday, November 21, 2009
Ubuntu Administration Tips
http://www.ubuntugeek.com/addmodify-and-delete-users-and-groups-in-ubuntu-using-gui.html
Ubuntu Linux 3 Years Ago
http://blogs.computerworld.com/15104/the_old_vs_the_new_linux_desktop
Thursday, November 19, 2009
Ubuntu App Store
Or, there are alternatives that functions the same, having a web-based approach. You just select the apps you like then install it with one-click. Haven't tried this yet but I've seen this from other sites and works pretty well.
http://tuxsoftware.com/?p=122
Really Nice Indeed!
http://www.dedoimedo.com/computers/kubuntu-9-10.html
Wednesday, November 18, 2009
Ubuntu 9.10: The Windows 7, Mac OSX Alternative
If you like a different looking desktop, which is similar to the Windows interface, download Kubuntu: http://kubuntu.org
If you have a netbook, download the Ubuntu Netbook Remix version in ubuntu website: http://ubuntulinux.org
If you have a slow computer like a Pentium II, download and install Xubuntu: http://xubuntu.org
If you are an artist, download Ubuntu Studio: http://ubuntustudio.org
If you are a student or you like to use it in schools for children, download Edubuntu:
http://edubuntu.org
If you like to use it to your business, download Ubuntu Server Edition in ubuntu website: http://ubuntulinux.org
Of course, you may install these different flavors on your default ubuntu install: System->Administration->Synaptic, search ubuntu-desktop (for Gnome), kubuntu-desktop (for KDE), xubuntu (for XFCE), edubuntu (For Education Ubuntu).
Read the review here: http://www.linuxinsider.com/rsstory/68639.html?wlc=1258191912&wlc=1258537549
Monday, November 16, 2009
Linux for Netbooks
http://blogs.zdnet.com/BTL/?p=27383
Netbooks are not just that fast like the notebook counterparts that is why of its low-cost. Because of this, Linux is a better candidate since it would run faster in slower processors that it would even run on Pentium II machines.
http://blogs.computerworld.com/15090/lenovo_returns_to_the_linux_desktop
Mount UDF (Live File System) Volume CD, DVD In Ubuntu 9.04
2.That's it!
Note: This is read-only; you cannot write to the CD or DVD.
Saturday, November 14, 2009
Autostart Linux Commands In Kubuntu 9.10, KDE 4
2.Click Properties, put a name, then Advanced Options.
3.Check Run In Terminal. Run as a Different User (if you're using a standard account), and choose the Administrator Username (This can be ommited using Opensuse 11.2).
4.That's it!
Ten Years of Desktop Linux
http://www.computerworld.com/s/article/9140169/Opinion_Linux_desktop_turns_10_world_yawns?taxonomyId=89&pageNumber=1
Friday, November 13, 2009
Removing Bouncing Cursor In Kubuntu 9.10 KDE 4
2.Choose No Busy Cursor. That's it!
Wednesday, November 11, 2009
Installing Software In Ubuntu 9.10
http://spiceminesofkessel.com/2009/11/11/a-beginners-guide-to-installing-software-in-ubuntu-9-10/
Installing Ubuntu Studio 9.10
http://www.howtoforge.com/the-perfect-desktop-ubuntu-studio-9.10
With this link, you will learn how to install Ubuntu Studio 9.10 step by step.
Graphics:
* The GIMP - free software replacement for Adobe Photoshop
* F-Spot - full-featured personal photo management application for the GNOME desktop
* Google Picasa - application for organizing and editing digital photos
Internet:
* Firefox
* Opera
* Flash Player 10
* FileZilla - multithreaded FTP client
* Thunderbird - email and news client
* Evolution - combines e-mail, calendar, address book, and task list management functions
* aMule - P2P file sharing application
* Transmission BitTorrent Client - Bittorrent client
* Azureus/Vuze - Java Bittorrent client
* Empathy IM Client - multi-platform instant messaging client
* Skype
* Google Earth
* Xchat IRC - IRC client
Office:
* OpenOffice Writer - replacement for Microsoft Word
* OpenOffice Calc - replacement for Microsoft Excel
* Adobe Reader
* GnuCash - double-entry book-keeping personal finance system, similar to Quicken
* Scribus - open source desktop publishing (DTP) application
Sound & Video:
* Amarok - audio player
* Audacity - free, open source, cross platform digital audio editor
* Banshee - audio player, can encode/decode various formats and synchronize music with Apple iPods
* MPlayer - media player (video/audio), supports WMA
* Rhythmbox Music Player - audio player, similar to Apple's iTunes, with support for iPods
* gtkPod - software similar to Apple's iTunes, supports iPod, iPod nano, iPod shuffle, iPod photo, and iPod mini
* XMMS - audio player similar to Winamp
* dvd::rip - full featured DVD copy program
* Kino - free digital video editor
* Sound Juicer CD Extractor - CD ripping tool, supports various audio codecs
* VLC Media Player - media player (video/audio)
* Helix Player - media player, similar to the Real Player
* Totem - media player (video/audio)
* Xine - media player, supports various formats; can play DVDs
* Brasero - CD/DVD burning program
* K3B - CD/DVD burning program
* Multimedia Codecs
Programming:
* KompoZer - WYSIWYG HTML editor, similar to Macromedia Dreamweaver, but not as feature-rich (yet)
* Bluefish - text editor, suitable for many programming and markup languages
* Quanta Plus - web development environment, including a WYSIWYG editor
Other:
* VirtualBox OSE- lets you run your old Windows desktop as a virtual machine under your Linux desktop, so you don't have to entirely abandon Windows
* TrueType fonts
* Java
* Read-/Write support for NTFS partitions
Lots of our desired applications are available in the Ubuntu repositories, and some of these applications have been contributed by the Ubuntu community.
These application list is provided by Falko Timme.
Another link for more applications: http://www.pcauthority.com.au/News/160222,5-more-free-linux-apps-you-cant-do-without.aspx
Monday, November 9, 2009
Ubuntu 9.10 vs. Windows 7
I've been using Ubuntu for three years now, and I'm an Ubuntu user ever since. I'm not saying that Windows is bad it's just that it's quite expensive, living in a poor country, having prices with the exchange rate in pesos, for me it's better to save money than spend it on original software that costs around P3,000 each. In Ubuntu, you got everything you need: photo editing, video editing, audio recording, office, etc. You just have to have time to learn these applications, which I did, just like learning in Windows.
I've downloaded the Windows 7 release candidate, and it's nice, but it's actually the same as any other OS, it's just another different interface. What matters most is that you can do your work with lesser problems and earn some money.
Sunday, November 8, 2009
How To Install Ubuntu 9.10 To A USB Drive, Pen-drive, Thumb-drive
http://news.softpedia.com/news/Installing-Ubuntu-9-10-126370.shtml
Few reminders:
1.In Hard Disk Partitioning, be sure to choose the USB Drive and not your hard disk. This is usually labeled what your brand of pen-drive you have.
2.In “Are you really ready for Ubuntu?” the final step, also be sure to choose your pen-drive not your hard disk or it will overwrite your existing boot loader.
3.That's it!
Where Is The Total Market Share of Ubuntu?
http://www.pcworld.com/article/181599/windows_7_sales_up_but_is_it_really_a_hit.html
Thursday, November 5, 2009
OpenOffice.org Writer Tips and Tricks
http://www.linux.com/news/software/applications/43783-lesser-known-features-in-openofficeorg-writer
How To Upgrade Ubuntu 9.04 to 9.10 Using An Alternate CD
http://mirror.anl.gov/pub/ubuntu-iso/CDs/karmic/
Only one caveat: I never tried using this procedure, I always do network upgrades using the Update Manager because it's much simpler.
Tuesday, November 3, 2009
Convert MIDI Files To MP3, OGG, and etc.
1.In Rosegarden, export to MIDI file.
2.Then, Convert to OGG using Sound Converter.
3.That's it!
Monday, November 2, 2009
Which Is The Fastest?
http://tuxradar.com/content/vista-windows-7-ubuntu-904-and-910-boot-speed-comparison
Sunday, November 1, 2009
Save Money, Use Open Source
http://news.cnet.com/8301-13505_3-10387512-16.html?part=rss&subj=news&tag=2547-1_3-0-20
Saturday, October 31, 2009
Ubuntu 9.10 vs. Snow Leopard vs. Windows 7
Friday, October 30, 2009
UBUNTU 9.10 IS OUT NOW!!!
http://education.zdnet.com/?p=3303
Wednesday, October 28, 2009
Ubuntu Founder Praises Windows 7
http://www.computerworld.com/s/article/9139907/Ubuntu_9.10_Linux_creator_calls_Windows_7_excellent_release_
Tuesday, October 27, 2009
The White House is Now Using Open Source
http://news.cnet.com/8301-30685_3-10382893-264.html
Tuesday, October 20, 2009
Monday, October 19, 2009
Sunday, October 18, 2009
The Linux Foundation Video Site:: Linux Pub (with subtiles)
You can use Linux to fix Windows machines.
Friday, October 16, 2009
The Linux Foundation Video Site:: Challenges at the Office
The office has its challenges, so watch this!
Robbert Bobbert and the Bubble Machine • We R Super Heroes
Check out this music video, "We Are Super Heroes" from Apples In Stereo!
Enjoy!
Wednesday, October 14, 2009
Enjoy!
Sunday, August 30, 2009
Java Basics Using Qt Jambi Tutorial
Download PDF version here.
The Table of Contents is located here.
Please make a small donation; it is very much appreciated. :)
This is the updated version. August 2009.
Thursday, August 27, 2009
Saturday, August 22, 2009
Nokia in Java Me: “Null Pointer Exception”
Sunday, August 9, 2009
Get Free Second Life Linden Dollars!
After your exploring, somehow, you will need to buy things. Even uploading images could cost something. Someone I chatted with someone recently and told me how I would earn money, called Lindens, eventually be successful in Second Life. Then, I came about MetaRL. It's a website where you can earn Linden dollars by playing their games, joining contest, or surveys, and most importantly, referrals. Here, you will earn meta points and convert it to Lindens for Second Life. You can learn more by visiting their website: www.metarl.com
Don't forget to add me in your referrals! http://www.metarl.com/register.php?referral=metarljhun
Thanks!
Saturday, August 8, 2009
Eclipse Galileo: Couldn't Run Jad, “manifest must have midlet-1”
2.Create Java Me Midlet with package name.
Friday, August 7, 2009
Saturday, June 13, 2009
Java Basics Using Qt Jambi Tutorial
QT Jambi
Now that we have discussed the basics of the Java Language, we move on to using Qt Framework in our Java Programs.
We are going to use an example project that would explain on how Qt works.
The program will be a photo slideshow with these requirements:
Import photos and show it.
Import music.
Play the slideshow.
Using Qt Designer
Qt designer is an interface that helps you design your application. Just like GUI designing in other IDE such as Visual Studio or Eclipse, Netbeans, etc.
When designing the GUI (Graphical User Interface), you can use the Qt Jambi Designer included in the Qt Jambi SDK or the Eclipse Qt Integration plugin. Since we are learning the fundamentals, it is better to use the Qt Designer that comes with Qt Jambi SDK, then convert the GUI you designed to Java code.
Since we already made our first application using the steps in “The Basics,” “Using Qt Designer,” we'll just tell you what to add in our photo slideshow.
List Widget
Text Label
Horizontal Slider
(3) Push buttons
Menu with these:
File->Import Photos->Import Music->Exit
It is recommended to rename these “widgets” using the Object Inspector Located on the right side of the designer by clicking the tab below. This will aid you on your coding for it is easier to remember because it will show up in your produced Java code and avoid variable name clashes by making it unique.
I won't write the source code here since it is not efficient, instead go to this http://javaqt.blogspot.com/2008/11/java-using-qt-jambi-tutorial-example.html and copy it.
The program works as it should, but it has “bugs” (errors) in it as to teach you Java using Qt Framework. Read the comments the ones after the “//” or “/*” and “*/”.
In the program or code, there are lines of code which I used String Builder, but a fixed array should be used instead.
In debugging (fixing) the code, I would suggest that you print out the variables or objects to see if the values it contain is correct (although, you can also see the values of variables on some decent IDEs like Eclipse, etc.) like,
System.out.println(variable); throughout the program.
In Java development, I always encounter problems on using class variables, like in a GUI in Qt, therefore add the keyword “static” so it would have one copy of that variable to use (this is also called static fields).
It is recommended that you read APIs (Application Programming Interface) documentation (and I know you would) and study it on how to use it. Search on the Internet for these or go to: http://java.sun.com/docs/books/tutorial/index.html download it, and the documentation included on the Qt Jambi SDK.
When creating a program, always think on solving one problem at a time, it is good practice that you design your program first on paper, but of course in reality, this isn't so.
Always make sure that you test your programs thoroughly before giving it to your boss because results matter.
So, I leave you with an unfinished program so you could experiment on. Happy Programming!
Friday, June 12, 2009
Java Basics Using Qt Jambi Tutorial
Generics
Generics makes it easy to catch runtime bugs such as wrong argument types. It tells the compiler to inform an error when there are wrong types, when a method call passes a string when it is expecting an integer.
Ex.
public class Vehicle{
private Object object;
public void start(Object object){
this.object = object;
}
public Object speed(){
return object;
}
public static void main (String[] args){
Vehicle v1 = new Vehicle(); created by different programmer
vi.start(“100”);
Integer speedofv = (Integer)v1.speed();
System.out.println(“speed of car is “ + speedofv);
}
} created by another programmer
This will result an error because it passes string where it expects an integer (this is at runtime not compile time).
Example on how to use generics:
public class Vehicle
private T t; //T stands for type
public void start(T t){
this.t = t;
}
public T speed(){
return t;
}
//we just replaced Object with T.
public static void main(String[] args){
Vehicle
v1.start(“100”);
Integer speedofv = v1.speed(); //no explicit casting
System.out.println(speedofv);
This will result an error in compile time having wrong types.
Type Convention:
T-type
N-Number
E-Element
V-Value
K-Key
You can also use generics in methods. The difference is it only accessed inside the method.
public<u>void direction(U u){
System.out.println(“T:” + t.getClass().getName());
System.out.println(“U:” + u.getClass().getName());
}
public static void main (String[] args){
Vehicle<integer>v1 = new Vehicle
v1.start(100);
v1.speed();
v1.direction(“North”);
}
prints out: T: java.lang.Integer
U:java.lang.String
to be continued...
Thursday, June 11, 2009
Java Basics Using Qt Jambi Tutorial
Packages
Packages is used to group related types which are classes, interfaces, enumerations and annotation types.
Ex.
//in UseCar.java
package com.cars.engine;
public interface UseCar{}
//in Vehicle.java
package com.cars.engine;
public abstract class Vehicle{}
3 Ways to access members:
Full qualified name. Ex. com.cars.engine.Vehicle;
Import package member. Ex. Vehicle v1= new Vehicle();
Import members entire package.
Ex.
import com.cars.engine.*;
Vehicle v1 = new Vehicle();
Car car1 = new Car();
Things you must remember with packages:
You must name packages with correct convention to make it unique and avoid name clashes.
Ex. package com.cars.engine;
Your class files should be located in the directories with names using the package name.
$javac -classpath /path/to/jar:/path/to/jar -d /path/to/folder/containing/java/files/ MyCar.java Vehicle.java $jar cfm MyCar.jar Manifest.txt /com/cars/engine/*.class $java -jar Main.jar |
to be continued...
Tuesday, June 9, 2009
Java Basics Using Qt Jambi Tutorial
Interface
Since we cannot have multiple instances using a class, we can use interfaces. Interfaces can implement from other interfaces.
Ex.
public interface UseCar{
int start (boolean ismoving,boolean key);
int stop (boolean ismoving,boolean breaks);
}
public class BMWCar implements UseCar{ //is used to provide methods declared from the interface.
int start (boolean ismoving, boolean key){
}
}
//is used so it can be available to any package to any classes. If omitted, it can be accessed to classes with same package.
Note: It can also contain constant declarations.
You must remember these rules in using Interfaces:
All the methods in interface should be declared on your source code.
Use public if you want to access the interface to any classes in any package.
When using or to access the interface methods through class instantiation implementing the interface.
Ex.
InterfaceVehicle.java
import java.lang.*;
public class InterfaceVehicle implements UseCar{
public int whichVehicleRunsFaster(int v1, int v2){
if (v1 > v2){
return v1;
}
else{
return v2;
}
}
public static void main(String[] args){
int car1 = 100;
int car2 = 200;
int cars;
InterfaceVehicle vehicle = new InterfaceVehicle();
cars = vehicle.whichVehicleRunsFaster(car1,car2);
System.out.println(cars);
}
}
UseCar.java
import java.lang.*;
public interface UseCar{
public int whichVehicleRunsFaster(int vehicle1, int vehicle2);
}
Note: Classes that implements this interface “inherit” the constants and must implement methods.
If an abstract class contains only abstract method declarations, it should be interface.
Monday, June 8, 2009
Java Basics Using Qt Jambi Tutorial
Classes
We've already seen classes from previous examples like class Vehicle. In object-oriented programming (OOP), we always create the most common or generalized class.
Ex.
public class Vehicle{
}
We created the class as Vehicle and from that, we put methods that is common to all vehicles.
Ex.
public class Vehicle{
public void accelerate(){
}
public void decelerate(){
}
public void start(){
}
public void stop(){
}
public void turnDirection(){
}
}
Then we create a “sub-class” called “Car”:
public class Car extends Vehicle{
public void turnOnRadio(){
}
public void turnOnWiper(){
}
}
And, also inheriting from Vehicle class we create:
public class Bicycle extends Vehicle{
public void adjustMirror(){
}
public void soundRinger(){
}
}
The Car and Bicycle are called sub-classes and Vehicle is the super class. We call this “inheritance.”
Then we can access the super class methods in our code.
Ex.
public static void main(String[] args){
Car car1 = new Car();
car1.start(); //since we inherited the methods in super class Vehicle, we can call its methods.
car1.accelerate();
car1.turnOnRadio(); //we can also use Car's own methods.
car1.stop();
Note: We can also use Vehicle's properties such as variables, constructors by using the super keyword, and even the super class' overriding methods.
Ex.
public class Vehicle{
public void start(){
System.out.println(“Start your engines”);
}
}
public class Car extends Vehicle(){
public void start(){
super.start();
}
}
Example of executing constructors in super class:
public class Vehicle{
public Vehicle(){
}
}
public class Car extends Vehicle{
public Car(){
super();
}
}
It can also pass in arguments:
public Car(int wheels, int doors){
super(wheels,doors)
}
to be continued...
Sunday, June 7, 2009
Java Basics Using Qt Jambi Tutorial
Parameters and Arguments – Parameters are what we pass in variables in methods. We already seen this in previous examples:
Ex.
import java.lang.*;
public class VehicleMoving{
public static int gear;
public static int speed;
public VehicleMoving(int gear){
this.gear = gear;
}
public void accelerate(){
switch(gear){
case 1:
speed = 10;
System.out.println("the car is moving at " + speed);break;
case 2:
speed = 20;
System.out.println("the car is moving at " + speed);break;
}
}
public static void main(String[] args){
VehicleMoving car = new VehicleMoving(1);
car.accelerate();
VehicleMoving car2 = new VehicleMoving(2);
car.accelerate();
}
}
Vehicle constructor expects one argument which is (1) with the parameter gear. 1 is an integer, so it must have data types int vehicle (int gear).
Remember these Rules:
The method call or class instance of constructors must have the same number of arguments or parameters.
The arguments passed-in should have the same data type.
to be continued...
Saturday, June 6, 2009
Java Basics Using Qt Jambi Tutorial
Constructors are used to initialize our variables but this is optional. As I've said, there is already a default constructor created for us.
Ex.
public class Vehicle{
public Vehicle(int wheels){
this.wheels = wheels;
}
}
There are rules in creating constructors:
It should have the same name as your class.
It does not have a return type.
You can create as many constructors provided you must have different number of parameters or different type.
Ex.
public class Vehicle{
public Vehicle(int wheels){
}
public Vehicle(String color, int doors){
}
public Vehicle(int gears, int steeringwheels){
}
}
Note: It is recommended you use different name for your parameters from the class variables.
Ex.
public class Vehicle{
public int trunk;
public String type;
public Vehicle(int wheels, int gears){
trunk = 1;
type = “car”;
wheels = 4;
gears = 6;
}
}
If you have same variable names for your parameters and class variables use the keyword “this.”
Ex.
public class Vehicle{
public int wheels;
public int gears;
public Vehicle(int wheels, int gears){
this.wheels = wheels;
this.gears = gears;
}
}
to be continued...Friday, June 5, 2009
Java Basics Using Qt Jambi Tutorial
Functions
Functions are also called methods. Functions are the verb or action for which your program will do.
Ex.
public class Vehicle{
plublic void accelerate(){
}
public void turnDirection(){
}
public static void main(String[] args){
Vehicle car = new Vehicle();
car.accelerate();
}
}
Here, we created the class Vehicle and inside the class are three functions: accelerate,turnDirection and the required main method.
In the main method, we created an instance of a class (can also be called “creating object”) Vehicle with the variable car. The “new” keyword creates the instance and executes the default constructor, then we call the method accelerate like car.accelerate(). This executes the code inside the function we defined accelerate. For our car to turn direction, we call the turnDirection method like this: car.turnDirection();
to be continued...
Thursday, June 4, 2009
Java Basics Using Qt Jambi Tutorial
Branching Statements
break; - The break statement terminates the loop.
continue; - when reached, it goes to the loop statement and evaluates the condition.
Ex. for (x=0; x<10;x++){
if (x==4){
continue;
}
System.out.println(x);
}
//this code prints from 0 to 3 and skips 4 and prints 5 to 9.
return;
Ex.
import java.lang.*;
public class AddNumbers{
public int add(int x,int y){
return x + y; //passes 1 and 2 then adds them and return the result
}
public static void main(String[] args){
boolean addnum = true;
AddNumbers num = new AddNumbers();
while (addnum){
System.out.println(num.add(1,2)); //passes 1 and 2 to add method and prints the result.
addnum = false;
}
}
}
to be continued...
Java Basics Using Qt Jambi Tutorial
Looping Statements
while, do-while statements – The while statement executes a block while the condition is true.
Ex.
import java.lang.*;
public class MovingCar{
static boolean ismoving = true;
static boolean breaks = false;
public static void main(String[] args){
while(ismoving){
if(breaks){
ismoving = false;
System.out.println("breaks is applied...stopped.");
}
else{
System.out.println("The car is moving.");
}
breaks = true;
}
}
}
This code prints “The car is moving.” once and breaks is applied and goes out of the while loop.
Do-while statements' difference is hat the condition is placed at the bottom and executes the block of code once.
Ex.
do{
//statements
}while (condition);
For Loop
Ex. for (x=0; x<10;>
//increment or decrement (x--)using unary operator
//initialization and executes once.
//Condition when met, or when it evaluates to false, it terminates.
System.out.println(x);
}
to be continued...Tuesday, June 2, 2009
Java Basics Using Qt Jambi Tutorial
Control Flow
Your code is usually executed from top to bottom. Control flow statements changes the flow of a program depending on a condition. There are 3 control flow statements.
Decision-making statements
if statement
Ex.
int wheels = 4; //declare and assign wheels to 4.
if (wheels == 4) {
System.out.println(“It is a car”); //executes this if wheel is 4.
}else if (wheels == 2){
System.out.println(“It is a bicycle”); //executes this if wheel is 2.
}else if (wheels == 1){
System.out.println(“It is a unicycle”);// executes this if wheel is 1.
}else{
System.out.println(“It is another vehicle”); //executes this if no other conditions are met.
}
Note: else if and else are optional.
In this example, we used the == equality operator rather than the assignment operator = to test for conditions.
Switch Statements – Switch statement works with:
Primitive data types
Enumerated types
Few classes like Integers, etc.
Ex.
int wheels = 4;
switch (wheels){
case 1: System.out.println(“unicycle”); break;
case 2: System.out.println(“bicycle”); break;
case 3: System.out.println(“tri-cycle”);break;
case 4: System.out.println(“car”);break;
default: System.out.println(“another vehicle”);
}
Example of Enumerated Types, Switch Statement
import java.lang.*;
public class enumVehicle{
enum Wheels{
ONE,TWO,FOUR //assign fixed set of constants.
}
Wheels wheels; //declare wheels variable having Wheels enum.
public enumVehicle(Wheels wheels){ //create constructor
this.wheels = wheels; //initializes variable
}
public void whatVehicle(){
switch(wheels){
case ONE: System.out.println("unicycle");break; //prints unicycle since we pass Wheels.ONE to constructor and assign it to wheels.
case TWO: System.out.println("bicycle");break;
case FOUR: System.out.println("car");break;
default: System.out.println("another vehicle");
}
}
public static void main(String[] args){
enumVehicle vehicle1 = new enumVehicle(Wheels.ONE); //execute constructor enumVehicle and assign Wheels.ONE to wheels.
vehicle1.whatVehicle(); //call whatVehicle method and print “unicycle.”
enumVehicle vehicle2 = new enumVehicle(Wheels.FOUR); //execute constructor enumVehicle and assign Wheels.FOUR to wheels.
vehicle2.whatVehicle(); //call whatVehicle method and print “car.”
}
}
to be continued...Java Basics Using Qt Jambi Tutorial
Operators, Expressions, Statements and Blocks
Operators – Operators are symbols that do something on operands.
Ex. 1 + 2
operator +
Operands can be variables with values in them.
int a = 1; //assign a to 1 called, which = is called assignment operators.
int b = 2; //assign b to 2
int c = a + b; //add a and b and give the result to c which is also type int.
System.out.println(c); //print result which is 3.
There are two kinds of operators:
Equality and Relational
== equal to
!= not equal to
> greater than
>= greater than or equal to
<>
<= less than or equal to
Conditional
&& Conditional-AND
|| Conditional-OR
Expressions – Expressions are made up of variables, operators or method calls.
Ex. int a = 1; //data type of a is int.
int b = 2; //data type of b is also int.
int c = a + b; //data type of c must be int.
Statements – Statements are logical lines which ends with a semi-colon.
Ex. int a = 1; //one statement
System.out.println(“Hello World!”); //one statement.
Note: A Statement always ends with a semi-colon.
Blocks – Blocks are made up of statements within curly braces:
Ex.
public static void main(String[] args){
int a = 1;
int b = 2; This is a block.
int c = a + b;
System.out.println(c);
}
or,
if (condition){
System.out.println(“Condition is true.”); This is a block.
}
else{
System.out.println(“Condition is false.”); else block
}
to be continued...
Monday, June 1, 2009
Java Basics Using Qt Jambi Tutorial
Identifier Naming
You just have to remember these rules in naming identifiers or variables.
Variable names are case-sensitive.
Begins with a letter or underscore.
Whitespace are not permitted.
Subsequent characters can be letters, digits, dollar sign or underscore.
Must not be a reserved word or keyword.
Good Naming Practices
Use full words like: wheels, speed, etc.
Do not use underscores as the first character.
If using more than one word, capitalize the first letter of the second word.
Ex. currentSpeed, currentDirections, etc.
When using constants, capitalize all letters and separate the next word by an underscore.
Ex. NUM_WHEELS;
to be continued...
Sunday, May 31, 2009
Java Basics Using Qt Jambi Tutorial
Variables
We've already used variables in our previous examples. Variables are identifiers that store values in your computer memory. There are four types of variables:
Instance variables – variables with unique values.
Ex. int wheels=4;
Class variables – variables with fixed value.
Ex. static in numSteeringWheel =1;
Local variables – can only be accessed inside a method block when placed inside it.
Ex. public void accelerate(){
int currentSpeed =20;
}
Parameters – variables inside method or constructors and exception handlers.
Ex. public static void main(String[] args) //args is the parameter with a String type of method main.
to be continued...
Saturday, May 30, 2009
Java Basics Using Qt Jambi Tutorial
String Builder Class
You can use this class to append or insert strings (just like concatenating strings, "String.concat()").
Ex.
String s =”hello”; //declare assign string “hello” to s.
StringBuilder sb=new StringBuilder(s); //creates an instance of class StringBuilder and puts the string s to sb StringBuilder.
sb.insert(4,”o”); //would insert the “n” inside the string “hello” and will be “helloo”.
sb.append(“world”); //will make “hello” string to “helloworld”.
Note: Append will always put the string at the end of the original string.
to be continued...
Friday, May 29, 2009
Java Basics Using Qt Jambi Tutorial
Numbers
Number class is used so you can utilize its methods for conversion or when an argument of a method expects an object.
Example of converting numeric values to numeric types using number class:
Number num=10; //create number data type
int numInt = num.intValue(); //convert Number to int data type
System.out.print(numInt);
Example of converting string to integer using integer class:
String s=”20”; //declare string variables to “20”
int numInt=Integer.parseInt(s); //converts string s to integer numInt
System.out.println(numInt); //print the int
Strings
From the previous example, we declared a string variable String s=”20”; The “20” Here is a string since it is enclosed by “”, which signifies it is a string not an integer or number and it is accompanied by the keyword String. We can also say String s=”hello there!”
Getting the Length of a String
Ex.
String s=”hello!”; //declare s as String and assign it to “hello!”
System.out.println(s.length()); //s.length since we assigned “hello!” to s, we access the String class method length to get the length of the string. System.out.println() prints the string.
Concatenating Strings or Joining Strings
Ex.
String s=”helloˍ̱̱̱“; //(“ˍ̱̱̱” is a space) declare s as string and assign s to “helloˍ̱̱̱“
System.out.println(s.concat(“world!”)); //concatenates or joins the string from s (which is hello) to “world!”, then prints the joined string.
Another way is,
String s=”helloˍ̱̱̱“ + “world!” //by using + to join or concatenate strings.
String Formatting
Example:
double doubleVar = 10.5; //declare and assign double 10.5.
int intVar=20; //declare, assign intVar to 20.
String stringVar=”hello!”; //declare and assign string var to “hello”
String fs; //declare fs as String.
fs=String.format (“The value of double var is %f, while the value of the “ + “integer variable is %d, and string is “+ “%s', doubleVar,intVar,stringVar); //Use method format of String class %f to assign the variable doubleVar, %d to intVar, %s to stringVar. These %f,%d,%s are called format specifiers which replaces the value in sequence after the (“”,)
Ex.
int i =10; //declare and assign value 10 to I;
String s = String.valueOf(i); //converts I to String using valueOf().
Note: you can use valueOf when converting to byte,integer,double,float,long and short.
Ex.
String s =”20”; //declare and assign string “20” to s.
integer a = Integer.valueOf(s); //converts s(20) to Integer a.
Getting Parts of a String
Ex.
String s = “hello world!”; //assign “hello world” to s as string.
String ss = s.substring(5,10); //returns “world”
0 1 2 3 4 5 6 7 8 9 10
h e l l o w o r l d
Note: Just remember the 5 is inclusion, and 10 is exclusion.
Other Methods You Can Use:
indexOf() //returns the index number of the string or char specified.
charAt() //returns the character where the index is specified.
trim() //removes the leading and trailing spaces.
toLowerCase() //returns a copy of string to lowercase.
toUpperCase() //returns a copy of string to uppercase.
to be continued...