Page 1 of 1

Basics to the Basics! Comp basics, Measuring memory, Errors, Hello World! Rate Topic: -----

#1 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Posted 26 July 2009 - 01:14 PM

Welcome to the first Fuzzy tutorial!

The tutorial will be shaped like this, will have an introduction to what you will learn in the particular tutorial, all of the tutorial contents, and finally at the end of the tutorial will be a list of definitions recapped that you will want to know for computer Programming. To clarify, I am using JCreator and you will also need to download the jdk1.6

In this first tutorial of my Java beginner Lessons, you will learn a couple things. Before you can begin programming you must understand the activity of programming, know about computers even if it is the slightest of knowledge, learn about machine code and high level programming languages as well as becoming familiar with your own compiler, you will also learn to compile and run your first Java Program, the classic “Hello, World!” and understand and recognize syntax versus logical errors.

To jump to any certain section of the Tutorial, you can use this Directory, simply highlight and copy the title, then hit ctrl + f and paste the title in the search zone. Click find and it will jump you directly to the section

Directory
What is programming?
Anatomy of a Computer
Bits, Bytes, and Codes
Measuring Memory
Machine Code
Java Programming Language
Hello, World!
Errors
API
Definitions

What is programming?

Computers are programmed to perform tasks, more then 1 simple or difficult task, because of this the different tasks = different programs.

What is a program?
It is a sequence of basic operations executed in succession; it should contain instruction sequences for all tasks it can execute. A program should be commented thoroughly and have Java Docs, we will get to that later.

Anatomy of a Computer
Central Processing Unit (CPU)
Chip (integrated circuit)
Transistors
Executes very simple instructions
Executes instructions very rapidly[/i]
Storage
Primary storage: Random-access memory (RAM)
Secondary storage: e.g. hard disk
Removable storage devices: e.g.: floppy disks, tapes, CDs

The CPU consists of a single chip or a small number of chips. Wiring on a chip is made principally from silicon.

The CPU locates and executes the program instructions; it carries out arithmetic operations such as addition, subtraction, multiplication and division; and it fetches data from storage and input/output devices and sends data back.

RAM – fast but expensive, and loses data when power is turned off (volatile)
Secondary storage (long term) – less expensive and non-volatile.

Bits, Bytes, and Codes

Bit is a Binary digit that is either 0 (off) or 1 (on).
1 Nibble = 4 bits
1 Byte = 8 bits.
1 Byte has 256 different numerical combinations.
2 Bytes has 65,536 different numerical combinations.
ASCII uses one byte to store one character.
Unicode uses two bytes to store one character.

Measuring Memory

KB* Kilo Byte 1 Thousand Bytes
MB Mega Byte 1 Million Bytes
GB Giga Byte 1 Billion Bytes
TB Tera Byte 1 Trillion Bytes
PB Peta Byte 1 Quadrillion Bytes
EB Exa Byte 1 Quintillion Bytes

*Technically, a kilobyte is exactly 210 or 1024 bytes.


Machine Code

- Machine code is computer instructions on the most basic level.
- CPU by different vendors has different sets of machine instructions.
- Java Virtual Machine (JVM) allows Java instructions to be executed on different CPUs.
- High-level languages allow you to describe tasks at a higher conceptual level than machine code.
- An interpreter translates high-level language to machine code one instruction at a time.
- A compiler translates a high-level language to machine code all at once.

Java Programming Language

- Designed to be simple
- Platform-independent ("write once, run anywhere") - JVM
- Rich library (packages)
- Designed for the internet - applets
- Safe – built in security features for web use


It is important to become comfortable with the organization of the computer you will be using to write your Java programs.

Understand files and folders
Programs are kept in files
File: a collection of items of information that are kept together
Files have names, and the rules for legal names differ from one system to another
Files are stored in folders or directories; these file containers can be nested
Save your work

- Develop a strategy for keeping backup copies of your work
You will use an Integrated Development Environment (IDE) to write your programs
Text editor
Compiler
interpreter
In our case, we will be using the JCreator to write our programs.


Now, on to your first program!!

Hello, World!

 public class HelloPrinter
 {
	public static void main(String[] args)
	{
	   
System.out.println("Hello, World!");
	}
}



Output: Hello,World!

public class ClassName 
{
	public static void main(String[] args)
	{ 
		// comment 
		System.out.println(“Hello, World!”);
	}
}



The ‘//’ is a sequence meant to show that it is a comment, it is meant for human readers and will not be read by the compiler

System This is an example of a class
System.out This is an object of a class
println This is a method in the class System of the object type out
(“Hello, World!”) These are parameters. Anything that is inside the ‘( )’ are params, are “Arguments” as you may find in some Java Books.


A method should always be invoked like this
object.methodName(parameters)

Example:
System.out.println("Hello, Dave!");

How would you modify the HelloPrinter program to print the words "Hello," and "World!" on two lines?
Answer: System.out.println(“Hello,”);
System.out.println(“World!”);

You have more then one way to print something, you can use println method which will print something then go to the next line, or you can use a print method, which will print something and stop after the last letter. So if you were to do this:

 System.out.print(“Hello,”);
System.out.print(“ World!”);



It would print the same thing as
System.out.println(“Hello, World!”);

You could also make it a combination of the 2; if you use a println then it will start off wherever the previous print was and print the statement and move to a new line.

System.out.print(“Hello, “);
System.out.println(“World!”);


You must make sure to add a space after ‘Hello,’ otherwise it will be printed right next to each other like this ‘Hello,World!’ which isn’t correct.

Errors

Syntax errors – Detected by the compiler
System.ouch.print(". . .");
System.out.print("Hello);
Logic errors - Detected (hopefully) through testing
System.out.print("Hell");
Runtime errors – Detected when program crashes or generates an error

One way to debug your program, or see if something is working, is by using println method. Have an Object that you need to know worked? Print it out! We will cover that in a different lesson.


API

The API is pretty much self explinatory, only thing I really have to say is that even if you cannot get online, you should have a “docs” folder in the Java Folder of the Programming Folders in the Local C: Drive. Inside the Docs folder is the API. If you don’t have one then you can download the docs for free from Here.

Well, I have finished my API tutorial and it has gotten approved, so to view a tutorial on the API, go Here!


Definitions

Sorry, but this is such a basic Tutorial and there is so few definitions worth remembering you will just have to go and look back on it! This section will be open for future tutorials!

Is This A Good Question/Topic? 4
  • +

Replies To: Basics to the Basics!

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 725
  • View blog
  • Posts: 4,471
  • Joined: 24-October 08

Posted 28 July 2009 - 05:49 AM

way to go fuzzy :^: , this was actually a great tutorial for beginners :^: ..awesome work
Was This Post Helpful? 0
  • +
  • -

#3 Nameless1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 16-July 09

Posted 01 August 2009 - 04:27 AM

nice work Fuzzy :^: :^: :^: :^:
Was This Post Helpful? 0
  • +
  • -

#4 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Posted 01 August 2009 - 03:16 PM

Thank ye thank ye! Figured not everyone who starts programming knows everything yet so a little review about smaller things with a slight intro to programming would be nice :)
Was This Post Helpful? 1
  • +
  • -

#5 sultan144  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 24-June 10

Posted 26 June 2010 - 06:08 PM

this was really nice fuzzy i hope u do more i really learn a lot specially as am a beginer!! SWEET
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1