Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,977 members, 7,821,415 topics. Date: Wednesday, 08 May 2024 at 12:40 PM

Java Programming For Dummies - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Java Programming For Dummies (40491 Views)

Programming For Dummies. / Vb.net For Dummies: / Vb.net For Dummies: (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (Reply) (Go Down)

Re: Java Programming For Dummies by Seun(m): 4:20am On Feb 16, 2006
I think it's better to teach the basics of Java with the Netbeans IDE+Java pack.
Re: Java Programming For Dummies by sbucareer(f): 5:07am On Feb 16, 2006


I agree with Seun, but people have different pace to learning. Eclipse may prove difficult at the initial stage, but if you have been doing some sort of programming before and have used some sort of IDE, then I will recommend downloading Netbeans+JDK 5.0 like Seun said.

This is the oficial website for Netbeans, you can find tutorials on quick start with java

Good Luck.

Re: Java Programming For Dummies by skima(m): 4:53pm On Feb 16, 2006
Am also working on attemptin the assignment. But i have not installed jdk. upto do that this weekend.
Re: Java Programming For Dummies by gbengaijot(m): 12:57am On Feb 17, 2006
@sbucareer, can u please tell me how to compile, i dont knw how to. I downloaded the TXTPAd which is an IDE and i download the Java SDK and i already did the configuration at the advance setup. But how will i compile?, i already copypaste the codes on to the IDE txtpad. so how do i compile ooooo.
someone tell me or else,, lol
I want to learn, am a dummy plzzzzzzzzzzzzzzzzz
give me a step by step instruction
Re: Java Programming For Dummies by skima(m): 1:07am On Feb 17, 2006
go to ur java directory and run this command;

example Note C:

C:\java> javac YourJavaFile.java

after that command u will have a YourJavaFile.class which is runable by the system
Re: Java Programming For Dummies by sbucareer(f): 1:08am On Feb 17, 2006

Click here or Google

Remember the java source file name must be the same with class name

Re: Java Programming For Dummies by olat(m): 1:16am On Feb 17, 2006
gbenga, this is what I did. Inside Textpad, go to Configure ---> Preferences --->
Re: Java Programming For Dummies by olat(m): 1:19am On Feb 17, 2006
gbenga, this is what I did.  Inside Textpad, go to Configure ---> Preferences --->
Click on Tools---> Complie Java
Click on Apply ---> ok

Then u 'll go back to Txtpad, after writing ur program.
Go to Tools and click on Compile Java, its a piece of cake, right, sbucareer, I am attempting ur assignment, shld be through @ the weekend.
Re: Java Programming For Dummies by sbucareer(f): 1:25am On Feb 17, 2006

Do this, click on tools and find compile when it has compiled successful, go back and click run. You must make sure you PATH is set

Re: Java Programming For Dummies by gbengaijot(m): 2:28pm On Feb 17, 2006
.
Re: Java Programming For Dummies by sbucareer(f): 8:16pm On Feb 17, 2006
[size=24pt][center]Tutorial addition[/size][/center]


Let look at Java Reserved keywords. What is java reserved work. These words are reserved as you cannot use any of these words as names in your programs. Remember that true, false, and null are not keywords but they are reserved words, so you cannot use them as names in your programs either.

What are names. It is refered to variable names, like in our above Radio software example, frequency and volume are variable names that holds information about the Object called Radio. Remember that variable names are devlopers choice, and can be confusing if a devloper do not choose appropriate name depicting the issue at hand.

Therefore java has come up with reserved keyword that can never be used or allowd to be used by developer to asigning their variable the reserved keywords. It is equally important you understand these keywords as you program will fail to compile if you used them.


[table]

[tr]
[td]abstract[/td][td]continue[/td][td]for[/td][td]new[/td][td]switch [/td][td][/td]
[/tr]

[tr]
[td]assert[/td][td]default[/td][td]goto[/td][td]package[/td][td]synchronized[/td][td]boolean[/td]
[/tr]

[tr]
[td] do[/td][td]if[/td][td]private[/td][td]this[/td][td]break[/td][td]double[/td]
[/tr]

[tr]
[td]implements[/td] [td]protected[/td][td]throw[/td][td]byte[/td][td]else[/td][td]import [/td]
[/tr]

[tr]
[td]public[/td] [td]case[/td][td]enum[/td][td]instanceof[/td][td]return[/td][td]transient [/td]
[/tr]

[tr]
[td]catch[/td] [td]extends[/td][td]int[/td][td]short[/td][td]try[/td][td]char[/td]
[/tr]

[tr][td]super[/td][td]while[/td][td]native[/td][td]class[/td][td]finally[/td]
[/tr]

[/table]

The keywords above are the ones I can remember, if you need to know all the keywords vist here
Re: Java Programming For Dummies by gbengaijot(m): 10:36pm On Feb 17, 2006
Have just got home now and do exactly waht i read. but i think am missing a point coz i just wasnt able to compile despite that i did conmfigure the preferences

Re: Java Programming For Dummies by sbucareer(f): 11:13pm On Feb 17, 2006

Gbenga, I can see you code has NOT been saved, as the name on the left navigational panel still says Document1*. The * means it has not been saved after the last modification. Besides, I told you that you must save the file as the same name as the class, for exaple.

If I have a class called HelloWorld like below

import java.lang.*;

public class HelloWorld extends Object{
  public static void main (String args[]){
         System.out.println("Hellow World"wink;
   }//End main
}//End program HelloWorld


I MUST save the class as HelloWorld.java

Re: Java Programming For Dummies by gbengaijot(m): 11:46pm On Feb 17, 2006
b

Re: Java Programming For Dummies by sbucareer(f): 12:20am On Feb 18, 2006


Ok, gbenga explain to me the problems you are having with texpad? Does it compile? Does it not run?  I want you to do something for me. Go to your command line, I can see you are using window XP. From the start button click run and type cmd and click ok.

The command line interface will come up, at the prompt type c:\>java -verson.  if you see this picture below that means your path is working if not you need to go here and configure your path

The textpad is not showing the compile option because it cannot see your path to java.

Re: Java Programming For Dummies by Seun(m): 12:34am On Feb 18, 2006
sbucareer:
Ok, gbenga explain to me the problems you are having with texpad?

That is why I suggested the use of the Netbeans IDE. Problems with Java should be about Java itself and not "Textpad" or other third party tools. With Netbeans, compiling your program is as easy as pressing a function key!
Re: Java Programming For Dummies by sbucareer(f): 12:39am On Feb 18, 2006


I have found another good IDE for java. Although I have not download and install it, I have otherwise read the requirements and people behind the development and it seems promising. The good thing about Dr java is that it is free.

If anyone is going to us it for this tutorial could you evaluate for like three weeks for us and post you thoughts about the IDE. It is a lightweight IDE. Gbenga, if you cannot get textpad to work I will recommend this as it does not require you to configure your path. Dr java comes with java 1.4 or 1.5 integrated into one download and does the whole path configuration all you need to do it write your code and compile.

Good luck

Note
-----------------

I agree with Seun, but people have their pace of learning and that does not make them incompetent. Netbean is easy to learn for people that have done some sort of programming in the past with other IDE and to adapt to new IDE will be easy. But in this case, a newbie cannot get textpad configured, it show how difficult it will really find Netbean. Mind you in Netbean, you have to add your jar to the environment which is like setting path, that could prove challenging to newbies.

But I see your point and would recommend it for intermediate programmers wanting to learn java.

Re: Java Programming For Dummies by olat(m): 5:53am On Feb 18, 2006
sbucareer, could u please, help me debug this error-just 1 error in compiling.
Meanwhile, I must just appreciate ur effort and ur patience.

Re: Java Programming For Dummies by mochafella(m): 6:36am On Feb 18, 2006
@olat,

Your physical file is named "Helloworld"
Your class is named "HelloWorld".

They both should be named "HelloWorld". Java is case-sensitive
Re: Java Programming For Dummies by olat(m): 7:07am On Feb 18, 2006
@mochafella,

Thanx bros, I have done that and it works. So cool, I'm moving on to sbucareer assignment.

Re: Java Programming For Dummies by sbucareer(f): 1:59pm On Feb 18, 2006


I will be looking forward to seeing everyones Object Diagram and the Temperature.java class soon. It is nice to see you guys working hard to get the textpad to compile HelloWorld. Now that is out of the way, let do some serious software engineering.

Remember to upload your diagram first with accompanying Classes and probably the TemperatureDemonstration.java as well. Those that completed these tasks are the ones I will respond to their questions.

Thanks again guys, you guys are brilliant learner, and believe me with this attitude soon you will become Sun Certified Java Associate (SCJA)

Re: Java Programming For Dummies by skima(m): 2:39pm On Feb 19, 2006
its funny when i discovered that the java compiler that i have been having problem to download comes with dreamweaver. I just discovered it to ("sunday"). and since tried to compiled the hello world app. i only save the file to the bin directory where the javac.exe exist and compile then ran, it worked straight away with textpad.

Java's cool. Am going with the assignment.
Re: Java Programming For Dummies by qleyo(f): 7:40pm On Feb 20, 2006
Hey, good job with the teaching SBU!

I do however think teaching everyone the basics of C would have been better, than expanding to C++ before touching Java.
That way people appreciate all three languages and see the difference between the former and java.

I've got over 4 years experience with C and 2 with C++ (software and embedded). I'm willing to help if you need anything.

We probably should do a seperate one for C.
Re: Java Programming For Dummies by olat(m): 8:01pm On Feb 20, 2006
@gleyo, we wouldn't mind learning from you too.
Its so sweet that u guyz, r willing to doll out from your knowledge and experience.
You could just give us sometimes to go a lenght with SBU on Java.

Let me quickly get back to my assignment, I've to submit tonight else SBUcareer may be discouraged.
Re: Java Programming For Dummies by skima(m): 9:44pm On Feb 20, 2006
@qleyo ill advice u(or some1 should) open a new thread for C/C++ , i dont think any knowledge is a waste.
Re: Java Programming For Dummies by skima(m): 8:54am On Feb 22, 2006
My assignment :

the diagram below

Re: Java Programming For Dummies by skima(m): 8:57am On Feb 22, 2006
import java.lang.Object

public class Temperature extends Object {

private int celsius = 0;
private int farhenheit = 0;
protected boolean tempOkay = false;

//i want to build the constructor now

public Temperature (int newcelsius, int newfarhenheit){


celsius = newcelsius;
farhenheit= newfarhenheit;
tempOkay= true;

}//end constructor


//build celsius method
public int getCelsius( ){
return celsius;
}//End getCelsius

public void setCelsius (int extCelsius){
celsius = extCelsius;
}//End setCelsius


public int getFarhenheit( ){
return farhenheit;
}//End getCelsius

public void setFarhenheit (int extFarhenheit){
farhenheit = extFarhenheit;
}//End setFarhenheit


public boolean isTemperatureOk(){
return tempOkay;
}//End isTemperatureOk


}//end class
Re: Java Programming For Dummies by skima(m): 9:00am On Feb 22, 2006
Demonstration class below:


import java.lang.Object;

public class TemperatureDemonstration extends Object {


//lets instantial our class , but at first set it to null
static private Temperature firstObject = null;
    static private Temperature secondObject = null;


public static void main (String args[]){

    //We are going to instantiate two objects we created above
      firstObject = new Temperature (32, 8 ) ;
      secondObject = new Temperature (55, 6);

       //Testing the new Objects or querying their attributes

   System.out.println ("Preset first object value: "+firstObject.getCelsius());
   System.out.println("Preset second object value: "+secondObject.getFarhenheit());


//Changing the identity of the objects we create above, hence assigning new values to their attribute.
  firstObject.setCelsius(3);
  secondObject.setCelsius(10);

  //Testing the new Objects or querying their attributes
   System.out.println ("New value for the first object: "+firstObject.getCelsius());
   System.out.println("New value for the second object: "+ secondObject.getCelsius());

//Lets check if temperature is ok
String tempVal=new String();
if(firstObject.isTemperatureOk()){
tempVal="Temperature is ok";
}

System.out.println(tempVal);
}// end print to system

}//end TemperatureDemonstration
Re: Java Programming For Dummies by skima(m): 9:04am On Feb 22, 2006
The classes have been compile and ran.

its will print if temperature is ok using the boolean method isTemperatureOk() built .
Re: Java Programming For Dummies by sbucareer(f): 5:38pm On Feb 22, 2006

Skima good work. I am impressed and very delightful that at least one person has attempted the task. You have showed great courage and good understanding and I will focus this tutorial around you and gbenga when I receive his work and other people.

Now, Skima your class diagram is very good but need a little modification like, the methods do not have bracket in Class Diagram . Every rectangle depicting method MUST show the reader if the method accepts/return attributes by using arrows. Out arrow i.e. -----------> will show that the method will return an attribute, <--------------- will show that the method will accept an attribute. Remember that if you method accepts/return several attributes must be shown using several arrows.

When you depict your attribute it is wise to say in the box what type of attribute that it. by doing this Celsius: String I know I did not showed it at the beginning but I was looking to see if any body will do some background reading to find this out by themselves. Off course that is the only way to learn, by doing additional reading.

Finally, you Temperature class has boolean attribute initialised to true. This can never happen. The Temperature class is a template. It will be instantiated into many objects in its later life, which will mean that all the Temperature artefact will be working/ok, which is NOT true.

Every attributes in a template class MUST be initialised to

1. Zero value in the case of int
2. Null value in the case of Object
3. false value in the case of boolean
4. 0.0 value in the case of double/float
5. '' in the case of char

In your TemperatureDemonstration is where you could have initialised that particular object to be working hence setting tempOk to true.

In general, you have done good work and I will progress to the second phase of my tutorial. I will compile the second phase when I get back from work. That will give others more time to upload their work if their have done it that is?




Re: Java Programming For Dummies by sbucareer(f): 5:57pm On Feb 22, 2006
[size=24pt]Class Diagram[/size]


Dont worry if your diagram do not look like this, with more practice you will become good in drawing class diagrams. Remember when you are in the work industry as a developer/programmer all you get is a Class Diagram or a UML Diagram and you must produce a software/codes base on the UML or class diagram. At the end of this tutorial I will help you to get started with UML

Re: Java Programming For Dummies by olat(m): 9:18pm On Feb 22, 2006
SBU, Please, find attached my assignment. I should have submitted earlier on Tuesday morning but for the fact that the system was down. I guess I miss out on the Class demonstration stuff. I will be awaiting ur comments.

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (Reply)

Nigerian Software Engineer given test to prove he is an engineer at JFK Airport / Facebook Is Suing Me For This / Learning To Program With Java by the Fulaman

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 53
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.