Programming References and tutorials for Developers.

c# ArrayList Class

By The Saint on Thursday, January 29, 2009

comments (2)

Filed Under:

c# ArrayList Class
Static arrays are not very useful when the size of an array is unknown in advance or is likely to change during the lifetime of a program. One solution to this problem is to use a type of array that automatically resizes itself when the array is out of storage space. This array is called an ArrayList and it is part of the System.Collections namespace in the .NET Framework library.

An ArrayList object has a Capacity property that stores its size. The initial value of the property is 16. When the number of elements in an ArrayList reaches this limit, the Capacity property adds another 16 elements to the storage space of the ArrayList. Using an ArrayList in a situation where the number of elements in an array can grow larger, or smaller, can be more efficient than using ReDim Preserver with a standard array.

Members of the ArrayList Class
The ArrayList class includes several methods and properties for working with ArrayLists. Here is a list of some of the most commonly used methods and properties:

- Add(): Adds an element to the ArrayList.
- AddRange(): Adds the elements of a collection to the end of the ArrayList.
- Capacity: Stores the number of elements the ArrayList can hold.
- Clear(): Removes all elements from the ArrayList.
- Contains(): Determines if a specified item is in the ArrayList.
- CopyTo(): Copies the ArrayList or a segment of it to an array.
- Count: Returns the number of elements currently in the ArrayList.
- GetRange(): Returns a subset of the ArrayList as an ArrayList.
- IndexOf(): Returns the index of the first occurrence of the specified item.
- Insert(): Insert an element into the ArrayList at a specified index.
- InsertRange(): Inserts the elements of a collection into the ArrayList starting at the specified
index.

Example:


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace ArraysBlogs
{
class Program
{
static void Main(string[] args)
{
//Creating an object 'list' derived from ArrayList class
ArrayList list = new ArrayList(16);

//Insertin value 1 and 2 to arraylist 'list'
list.Add(1);
list.Add(2);

//Accessing the value in an Arraylist 'list'
//displaying value 1 and 2 on the screen

Console.WriteLine(list[0]);
Console.WriteLine(list[1] + "\n");

//Creating an integer array a
int[] a = new int[10];

//Inserting a value 10,20,30 to array 'a'
a[0] = 10;
a[1] = 20;
a[2] = 30;

//Adding range of elements from array 'a' to Arraylist 'list'
list.AddRange(a);

//Displaying the value of Arraylist list using foreach()

foreach (object getList in list)
{
Console.WriteLine(getList);
}

//Getting the capacity of an Arraylist 'list'
//It will display 16 as it was specified.

Console.WriteLine("Capacity of list: " + list.Capacity);
Console.ReadKey();
}
}
}


c# Jagged Arrays

By The Saint on Thursday, January 29, 2009

comments (0)

Filed Under:

c# Jagged Arrays
When you create a multidimensional array, you always create a structure that has the same number of elements in each of the rows. For example, look at the following array declaration:

int[,] month = new int[12,30]; //Day of each month

This array assumes each row (month) has the same number of elements (days), when we know that some months have 30 days, some have 31, and one month has 29. With the array we’ve just declared, there will be several empty elements in the array. This isn’t much of a problem for this array, but with a much larger array we end up with a lot of wasted space.

The solution to this problem is to use a jagged array instead of a twodimensional array. A jagged array is an array of arrays where each row of an array is made up of an array. Each dimension of a jagged array is a onedimensional array.We call it a “jagged” array because the number of elements in each row may be different. A picture of a jagged array would not be square or rectangular, but would have uneven or jagged edges.

A jagged array is declared by putting two sets of parentheses after the array variable name. The first set of parentheses indicates the number of rows in the array. The second set of parentheses is left blank. This marks the place for the one-dimensional array that is stored in each row. Normally, the number of rows is set in an initialization list in the declaration statement, like this:

int[][] month = new int[12][];

This statement looks strange, but makes sense when you break it down. jagged is an Integer array of 12 elements, where each of the elements is also an Integer array. The initialization list is actually just the initialization for the rows of the array, indicating that each row element is an array of 12 elements, with each element initialized to the default value.

To initialize the size n element of the inner array:

month[0] = new int[31]; // for the month of Jan
month[1] = new int[29]; // for the month of Feb
month[2] = new int[31]; // for the month of Mar
. . .
month[11] = new int[31]; // for the month of Dec



Once the jagged array is declared, the elements of the individual row arrays can be assigned values. The following code fragment assigns values to jaggedArray:

month[0][0] = 23;
month[0][1] = 13;
. . .
month[7][5] = 45;

The first set of parentheses indicates the row number and the second set indicates the element of the row array. The first statement accesses the first element of the first array, the second element access the second element of the first array, and the third statement accesses the sixth element of the eighth array.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArraysBlogs
{
class Program
{
static void Main(string[] args)
{
int[][] month = new int[12][];

month[0] = new int[31];
month[1] = new int[29];
month[2] = new int[31];

//Inserting a values in jagged Array

month[0][0] = 25;
month[0][1] = 50;
month[0][2] = 75;
month[1][0] = 85;
month[1][1] = 95;
month[1][2] = 105;

//Accessing the values in jagged Array
Console.WriteLine(month[0][0]);
Console.WriteLine(month[0][1]);
Console.WriteLine(month[0][2]);
Console.WriteLine(month[1][0]);
Console.WriteLine(month[1][1]);
Console.WriteLine(month[1][2]);

Console.ReadKey();
}
}
}



Free Alternative for visual c#

By The Saint on Sunday, January 25, 2009

comments (0)

Filed Under:

Free Alternative to visual Studio.net c#
Visual Studio.net developers who are looking for a good and cheaper open source alternative that delivers the same look and feel of visual studio.net.

#develop (short for SharpDevelop) is a free IDE for C#, VB.NET and Boo projects on Microsoft's .NET platform. It is open-source, and you can download both source code and executables.











Sharp Develop Screenshots


Product Features

SharpDevelop is an Integrated Development Environment (IDE) for .NET Framework applications. It supports the development of applications written in C#, Visual Basic.NET and Boo. It is open source and written in C#. It provides all of the features required from a modern Windows IDE, such as code completion, project templates, an integrated debugger and a forms designer. It has good compatibility with Visual Studio Express and Visual Studio 2005 by using the same project and solution file format.

Here is a quick tour showing you the main features of SharpDevelop.
Additional Product Features

  • Forms designer for C#, VB.NET and Boo
  • Code completion for C#, VB.NET and Boo (including Ctrl+Space support)
  • Integrated NUnit support plus code coverage (NCover)
  • Integrated debugger
  • Code Analysis with FxCop
  • Refactoring support
  • Multi-framework support (.NET 1.1 and 2.0, Mono, Compact Framework)
  • XML Editing (source and tree view) with XPath search
  • Parser-based code converter (C# to VB.NET / Boo and more)
  • Compile C#, VB.NET & Boo code in the IDE out-of-the-box
  • Code AutoInsert (Alt+Ins)
  • Xml documentation preview
  • Setup projects supported with Windows Installer XML (WiX)
  • Subversion integration
  • Open source, LGPL licensed
And here are some more...
  • User interface translated to many languages
  • Write C#, ASP.NET, ADO.NET, XML, HTML code
  • Project or File-based development (Project Scout & File Scout)
  • Rich project options
  • Syntax highlighting for C#, HTML, ASP, ASP.NET, VBScript, VB.NET, XML
  • Intelligent braces
  • Folding
  • Bookmark your code
  • Code template support
  • Component Inspector
  • Feature-rich Find & Replace dialogs (including incremental search)
  • Easily extensible with external tools
  • Easily extensible with Plug-Ins
  • Re-host SharpDevelop with SDA
  • ... and much more

If you want to read more about the product and its latest releases then visit this link

To download the software just click here

Features of Java Program

By The Saint on Tuesday, January 20, 2009

comments (0)

Filed Under:

Features of Java Program


The Java Virtual Machine
Java Virtual Machine is a piece software and data structures that is implemented to emulate software and scripts on a real machine. The Java Virtual Machine provides the hardware a platform to which you compile all Java code. By doing this it enables all programs written in Java program as a platform-independent because it compiles the code to a generic machine known as the JVM.

bytecode
A Java generated source code after compilation is known as bytecode. Bytecode is a platform-independent, so any computer with a java interpreter can compile the program even what type of machine you are using.

Garbage Collection
Common feature of a programming language is to allocate memory address every time user execution the program. However, after using the allocated memory, deallocating unused block of memory could be the problem in some programming languages. Deallocation of memory is done manually like in c and c++ programmers has the responsibility to deallocate blocks of memory, but there are some instance that programmers forget to deallocate memory and can cause to memory leaks.

In Java freeing block of memory is not a problem to programmers but instead Java program itself has the capability to free unused memories and that is the task preformed by the Garbage Collection Thread.

CSS Styling Images and Classes video

By The Saint on Sunday, January 18, 2009

comments (0)

Filed Under:

CSS Styling Images and Classes | Dreamweaver CS3 Tutorial

CSS Classes and Styling Images tutorial using Dreamweaver CS3. It's a great tutorial found in YoutTube.

In this video we will cover CSS classes and the creation and application of them. We will apply page-wide class styles as well as being a bit more specific with the selectors we use. Great for beginners and Intermediates alike!


video posted by: tutvid

What is Java Technology?

By The Saint on Saturday, January 17, 2009

comments (0)

Filed Under:

What is Java Technology?


Programming language
Java can develop any application that surpasses the user expectation; it includes mobile programs, web applications, windows form application, tools and services that can run on different platform.

Development environment
Java package provides you with a large suite of tools: compiler, interpreter, documentation generator, a class packaging tool, and other tools that help you in application development.

Application environment
Java technology applications are platform independent programs that run on any machine where the Java runtime environment (JRE) is installed.

Deployment environment
Two deployment environments: Includes, the JRE supplied by the Java 2 Software development Kit (SDK) contains the complete set of class files for all the Java technology packages, which includes basic language classes, GUI component classes, and so on. The other main deployment environment is on your web browser. Most commercial browsers supply a Java technology interpreter and runtime environment.


Advantages of open-sourcing Java technology implementations
Video posted by: FinanMart

Introduction to Java Programming

By The Saint on Saturday, January 17, 2009

comments (0)

Filed Under:

Introduction to Java Programming

A little bit of Java History

Java was created in 1991 by James Gosling and his team called the green team as mall group of engineers, of Sun Microsystems. At fist Java was called as Oak, then it was changed to Java because their was already a language called Oak.

The drive in creating Java was to developed a language that could support digital consumer devices and computers and can run on different platform. One of the successful developments was the star 7 hand held remote control used in cable television industry. And in 1995, the demand of internet technology is increasing; Gosling and his team realized that Java could be used in internet programming.

These days, java gain its reputation not just on internet application but also on different hand held devises.


James Gosling - Thoughts for Students
Video posted by: tgmallery

Adding background using css

By The Saint on Wednesday, January 14, 2009

comments (0)

Filed Under:

Adding background using css

Web page backgrounds used to be usual, but they became unpopular once designers figured out that visitors to web pages didn’t want their eyes wrenched out by flashy tiled background patterns. A good combination of background colors can add text clarity, and readability and attractiveness.
With the help of CSS adding backgrounds is more flexible you can have the control over background image that you append. Changing of positions, and background repetition is easy. The following example will show you on how to do this.

background-color
This property sets the background color of the element. The
page’s body background color has been set to #000000 (which is hex):
body {
background-color: #000000
}

background-image
This property sets a background image for the relevant element:
body {
background-image: url(ProjectUno_background_image.jpg);
}

By using this CSS, you end up with a tiled background

background-repeat
You can have a background image repeat vertically, horizontally, in both directions, or in neither direction. The background-repeat property can accept four values, the default is repeat, creating
the tiled background.

div {
background-image: url(ProjectUno.jpg);
background-repeat: repeat; }
ol {
background-image: url(ProjectUno.jpg);
background-repeat: repeat-x;}
u1 {
background-image: url(ProjectUno.jpg);
background-repeat: repeat-y;}
p {
background-image: url(ProjectUno.jpg);
background-repeat: no-repeat;}

Watch java array video tutorial

By The Saint on Tuesday, January 13, 2009

comments (0)

Filed Under:

Watch java array video tutorial

Having trouble in using arrays in java? Please watch this video it will help you.
This video will show you simple array tutorial: array declaration, array initialization, accessing and assigning values in an array and etc.

watch basics of java array
video posted by: aphonik


Secrets of css content layouting

By The Saint on Tuesday, January 13, 2009

comments (0)

Filed Under:

Secrets of css content layouting

The best way to layout your content is by using a combination of CSS and div instead of tables.
Tables is easy to use to layout a page rather than using a div, but the dilemma in using this is that it generates complex structures on your html codes, it adds more tags (<td>, <tr>) to the html compared of having a layout designed using div.

learn css content layouting

Advantages of using CSS and div over tables;
1. Reusability of css codes.
2. flexibility and code optimization
3. Searchable content for search engine optimzation.

Disadvantage of div
1. It requires more knowledge about css

This sample will show you the different mixtures in lay outing a content using CSS and div.

This sample works on IE 6 and other compliant browsers.

--- CSS Codes ----

body{
margin: 0px;
}
.container{
width:990px;
margin:auto;
background-color:#EFEFEF;
border: 1px solid #CCCCFF;
padding:0px;
}
.top{
height:100px;
background-color:#CCCCFF;
}
div.contentWrappers{
margin:auto;
padding:0px;
}
div.contentWrappers ul{
list-style-type:none;
text-decoration:none;
margin:0px;
padding:10px;
font-size:large;
border-bottom:1px silver dotted;
}
div.contentWrappers ul li{
display:block;
font-size:small;
font-weight:normal;
margin-top: 5px;
}
div.content-table{
margin:auto;
padding:0px;
}
div.content-table ul{
overflow:auto;
list-style-type:none;
text-decoration:none;
margin:0px;
padding:0px 0px 5px 5px;
}
div.content-table ul li{
float:left;
width:200px;
height:164px;
font-size:small;
font-weight:normal;
text-align:left;
}
div.content-table li.content-2ndcol{
width:550px;
height:165px;
font-size:small;
font-weight:normal;
text-align:left;
}
div.content-table li.content-spacer{
clear:both;
}
div.contentDownloads{
margin:auto;
padding:0px;
text-align:center;
}
div.contentDownloads div{
float:left;
margin:0px;
padding:0px;
width:200px;
}
div.contentDownloads div ul{
list-style-type:none;
padding:5px 0px 10px 5px;
margin:0;
font-size:small;
font-weight:bold;
}
div.contentDownloads div ul li{
padding:0px;
display:block;
margin:0;
font-size:small;
font-weight:normal;
text-align:left;
}

.clearer{
clear:both;
padding:0px;
margin:0px;
}
.contents{
width:770px;
background-color:white;
text-align:left;
padding:5px 5px 5px 5px;
font-family:Arial, Helvetica, sans-serif;
font-size:small;
min-height:400px;
}
div.rightnav{
float:right;
width:195px;
padding: 5px 5px 5px 5px;
font-family:Arial, Helvetica, sans-serif;
margin:0px;
}
div.rightnav ul{
list-style-type:none;
padding:0;
margin:0;
font-size:medium;
font-weight:bold;
}
div.rightnav ul li{
margin-top:4px;
font-size:small;
font-weight:normal;
}
.rightnav ul li a{
display:block;
width: 175px;
padding: 3px 5px 3px 10px;
text-decoration: none;
color: #000;
}
.rightnav ul li a:hover{
color:black;
background-color:silver;
display:block;
}
.rightnav ul li:hover > ul{
background-color:silver;
display:block;
color:maroon;
position:relative;
}
.rightnav ul li ul{
display:none;
top:0px;
width:175px;
padding-left: 15px;
}
.footer{
clear:both;
height:50px;
background-color:#CCCCFF;
}




--- HTML Codes ----


<div class="container">
<div class="top"></div>
<div class="rightnav">
<ul>
<li>Menu sample</li>
<li><a href="#">Menu 1 </a>
<ul>
<li>Sub menu 1</li>
<li>Sub menu 2</li>
<li>Sub menu 3</li>
<li>Sub menu 4</li>
</ul>
</li>
<li><a href="#">Menu 2</a>
<ul>
<li>Sub menu 1</li>
<li>Sub menu 2</li>
<li>Sub menu 3</li>
<li>Sub menu 4</li>
</ul>
</li>
<li><a href="#">Menu 3</a>
<ul>
<li>Sub menu 1</li>
<li>Sub menu 2</li>
<li>Sub menu 3</li>
<li>Sub menu 4</li>
</ul>
</li>
</ul>
</div>
<div class="contents">
<div class="contentWrappers">
<ul>
<li>
<img alt="" height="330" src="Project-uno.jpg" width="583" /></li>
<li>Title 1</li>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</li>

</ul>
<ul>
<li>
<img alt="" height="291" src="Project-uno.jpg" width="326" /></li>
<li>Title 2 </li>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</ul>
</div>
<div class="contentDownloads">
<div>
<ul>
<li>
<img alt="" height="162" src="Project-uno.jpg" width="187" />
</li>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</li>
</ul>
</div>
<div>
<ul>
<li>
<img alt="" height="162" src="Project-uno.jpg" width="187" />
</li>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</li>
</ul>
</div>
<div>
<ul>
<li>
<img alt="" height="162" src="Project-uno.jpg" width="187" />
</li>
<li>Download the trial version of iWork '08 now and try it for yourself. You'll be making gorgeous documents, presentations, and spreadsheets in minutes.</li>
</ul>
</div>
</div>
<div class="clearer"></div>
<div class="content-table">
<ul>
<li>
<img height="162" src="Project-uno.jpg" width="187" /></li>
<li class="content-2ndcol">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</li>
<li>
<img height="162" src="Project-uno.jpg" width="187" /></li>
<li class="content-2ndcol">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</li>
</ul>
</div>
</div>
<div class="footer"></div>
</div>

Watch css div layer tutorial

By The Saint on Monday, January 12, 2009

comments (0)

Filed Under:

Watch css div layer tutorial

A sample video tutorial from you tube on how to design a page using class as css declaration and div layers. A simple tutorial for beginners. Please watch the video.

Watch css div and classes video Posted by: lifeg0eson666

Watch css sample tutorial

By The Saint on Monday, January 12, 2009

comments (0)

Filed Under:

Watch CSS sample tutorial

Learn the basics and secrets of CSS and HTML in 39:20 sec.
A simple tutorial that will give ideas on how to design a web using a combination of CSS and HTML.

Watch css sample video tutorial Posted by: jimmyrcom in youtube

C# linked list tutorial | linked list in C#

By The Saint on Monday, January 12, 2009

comments (0)

Filed Under:

C# Linked List Tutorial | linked list in C#
In our everyday life we encounter list: creating a list for a day-to-day task, a list for our favorite songs and name in our phonebooks. In this sample tutorial we will look at one particular type of list, the linked list. A.Net framework contains list-based collection classes, but linked list was not considered as part of the framework library. These tutorials will explain to you why linked list is needed in the program, a sample code of an object based linked list and array-based linked list.

How Arrays described?
Array is considered as the simplest form of data structure when storing multiple data in your program. Insertion and retrieving of data can be done easily by just specifying its index when invoking an array. Array is already part of the language so it does not require extra memory and processing time when it is used in the program.

Major drawbacks of Arrays
Common drawbacks in using static arrays are that, it lacks the flexibility to handle data that grows dynamically during runtime, searching of elements in unsorted array element is dawdling or slow for it has possibly visits the entire element in the array. Addition and deletion of elements is quite difficult for it has to shift the elements to avoid errors.

What is Linked List?
A linked list is a collection of class objects called nodes that have the characteristic to grow and shrink during runtime. Each node is linked to its successor node in the list using a reference to the successor node. A node is made up of a field for storing data and the field for the node reference. The reference to another node is called a link.

Comparing Linked list to an Array
A major difference between an array and a linked list is that the elements of a linked list are referenced by their relationship to the other elements of the array, whereas the elements in an array are referenced by position (the index).

AN OBJECT-ORIENTED LINKED LIST
In designing an Object-Oriented linked list involves at least two classes: A Node class and a node object instantiated to a Node Class each time we add a node to the list. The nodes in the list are connected via references to other nodes through an element called pointer which holds the address of the next node object. These references are set using methods created in a separate Linked List class.

Element of a Node Class
A Node Class is consists of different elements or fields these are: Data field and Pointer or address field. A Data field holds the actual data of a Node object while pointer field holds the address node of the next node object in the list. Purpose of this is to link the nodes in a list.

This is what linked list look like after inserting values (21-24).

This example will show you how it is done, just copy and past the source code on your program.

Here’s a sample code of a node class. (Filename: Node.cs)

using System;

namespace LinkedListSample{

class Node
{
private Node _next;
private object _data;

public Node()
{
_next = null;
}
public Node next
{
get
{
return _next;
}
set
{
_next = value;
}
}
public object data
{
get
{
return _data;
}
set
{
_data = value;
}
}
}
}


Single Linked List Class (Filename: SLL.cs)

using System;
using System.Collections;

namespace LinkedListSample{

public class SingleLinkedList
{
private Node head;
private Node tracer;

public SingleLinkedList()
{
head = null;
tracer = null;
}
public void insertNode(object data)
{
if(head==null)
{
head = new Node();
tracer = head;
head.data = data;
}
else
{
Node tempNode = new Node();
tempNode.data = data;
tracer.next = tempNode;
tracer = tempNode;
}
}
public void deleteNode(object data)
{
Node temp;
temp = head;

if(head.data.ToString() == data.ToString())
{
head = head.next;
temp = head;
}
else
{
while(temp != null && temp.next != null)
{
if(temp.next.data.ToString() == data.ToString())
{
temp.next = temp.next.next;
if(temp.next == null)
{
tracer = temp;
}
}
temp = temp.next;
}
}
}
public void traverse()
{
Node temp = head;


while (temp != null)
{
Console.Write(temp.data + " ");
temp = temp.next;
}
}
}

}




Linked List Implementation. (Filename: Main.cs)

using System;

namespace LinkedListSample{
class Program
{
public static void Main(string[] args)
{
// TODO: Implement Functionality Here
SingleLinkedList list = new SingleLinkedList();
int data=0;
Console.WriteLine("Insert node: 21, 22, 23, 24, 25 ");
list.insertNode(21);
list.insertNode(22);
list.insertNode(23);
list.insertNode(24);
list.insertNode(25);
list.insertNode(27);
Console.WriteLine("Output after insertion: ");
list.traverse();
Console.WriteLine("\n\nDelete Node 24: ");
Console.WriteLine("Output after deletion: ");
list.deleteNode(24);
list.traverse();
Console.WriteLine("\n\nDelete Node 22: ");
Console.WriteLine("Output after deletion: ");
list.deleteNode(22);
list.traverse();
Console.WriteLine("\n\nInsert node: 26 ");
list.insertNode(26);
Console.WriteLine("Output after insertion: ");
list.traverse();
Console.WriteLine("\n");
}
}
}

Learning java array | Java Array Tutorial

By The Saint on Sunday, January 11, 2009

comments (1)

Filed Under:

Learining Java Array

What is an array? An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.

It means that, if I have to store multiple integer numbers I can simply declare a single integer array and simply specify its dimension, To make more clear I will how it works:

First I will discuss how arrays are declared in the program

Array Source code:

Syntax:
       <data type> <array-name>[] = new <data type>[<size n>];
-Or-
int projectuno[] = new int[5];


public class IntNumbers
{

public static void main(String args[])
{
int num[] = new int[7];
}

}

That’s quite simple.

Array containing 5 integer values of type int called projectuno could be represented like this:




Inserting a value in an Array

Inserting a value in an array is quite simple you simply invoke its array name plus the index.

Ex.:
projectuno[0] = 1;
projectuno[1] = 10;
projectuno[2] = 100;
projectuno[3] = 1000;

projectuno[4] = 200;
projectuno[5] = 20;
projectuno[6] = 2;

By doing this you simply filled up all the index of the array projectuno.




Note:
All values added in the array must be on the same data type.
Error: projectuno[0] = “Hello”;

Specifying an index higher than the declared size can create errors in the program.
Error: projectuno[10] = 300;

Index of an Array don’t accept negative value.
Error: projectuno[-1] = 400;

Accessing a value in an Array
We can access a value in array by accessing its index the same way we did as we add a value in an array. Like an ordinary variable we can access the value individually.

Example:
System.out.println(projectuno[0]);
System.out.println(projectuno[1]);
System.out.println(projectuno[2]);
System.out.println(projectuno[3]);
System.out.println(projectuno[4]);
System.out.println(projectuno[5]);
System.out.println(projectuno[6]);



Sample Problem:
Create a program that will display 7 integer numbers using array.
Ouput:
1
10
100
1000
200
20
2

Solution:
public class IntegerNum
{
public static void main(String args[])
{
int projectuno[] = new int[7];
projectuno[0] = 1;
projectuno[1] = 10;
projectuno[2] = 100;
projectuno[3] = 1000;
projectuno[4] = 200;
projectuno[5] = 20;
projectuno[6] = 2;

System.out.println(projectuno[0]);
System.out.println(projectuno[1]);
System.out.println(projectuno[2]);
System.out.println(projectuno[3]);
System.out.println(projectuno[4]);
System.out.println(projectuno[5]);
System.out.println(projectuno[6]);
}
}



Multidimensional Array
A multidimensional array consists of two or more arrays defined by sets of array elements, Each set of array elements is an array. The first set of array elements is considered the primary array, and the second and subsequent sets of array elements are considered subarrays.

Two dimensional Array
Two dimensional Array can be viewed as matrix or table.

Syntax in declaring a Two dimensional Array

data type array_name = new type[row size][col size];

Example:
int projectuno[][] = new int[2][4];









Inserting a value in Two dimensional Array

Inserting a value in an array is quite simple you simply invoke its array name plus the index for row and column.

Example:
projectuno[0][0] = 2;
projectuno[0][1] = 4;
projectuno[0][2] = 6;
projectuno[0][3] = 8;
projectuno[1][0] = 3;
projectuno[1][1] = 6;
projectuno[1][2] = 12;
projectuno[1][3] = 15;


Accessing a value in an Array
We can access a value in multidimensional array by accessing its indexes the same way we did as we add a value in an array.

Example:
System.out.println(projectuno[0][0]);
System.out.println(projectuno[0][1]);
System.out.println(projectuno[0][2]);
System.out.println(projectuno[0][3]);
System.out.println(projectuno[1][0]);
System.out.println(projectuno[1][1]);
System.out.println(projectuno[1][2]);
System.out.println(projectuno[1][3]);

Object-Oriented programming concept

By The Saint on Thursday, January 08, 2009

comments (0)

Filed Under:

What is Object-Oriented programming?

Object-Oriented programming or OOP revolves around the concept of objects as the basic elements of your programs. When we compare this to the physical world, we can find many objects around us, such as cars, lion, people and so on. These objects are characterized by their properties (or attributes) and behaviors. For example, a car object has the properties, type of transmission, manufacturer and color. Its behaviors are turning, braking and accelerating. Similarly, we can define different properties and behavior of a lion.

With these descriptions, the objects in the physical world can easily be modeled as software objects using the properties as data and the behaviors as methods. These data and methods could even be used in programming games or interactive software to simulate the real-world objects! An example would be a car software object in a racing game or a lion software object in an educational interactive software zoo for kids.

Difference between a Class and an Object

In the software world, an object is a software component whose structure is similar to objects in the real world. Each object is composed of a set of data (properties/attributes) which are variables describing the essential characteristics of the object, and it also consists of a set of methods (behavior) that describes how an object behaves. Thus, an object is a software bundle of variables and related methods. The variables and methods in a Java object are formally known as instance variables and instance methods to distinguish them from class variables and class methods, which will be discussed later. The class is the fundamental structure in object-oriented programming. It can be thought of as a template, a prototype or a blueprint of an object. It consists of two types of members which are called fields (properties or attributes) and methods. Fields specifiy the data types defined by the class, while methods specify the operations. An
object is an instance of the class.

When instantiated, each object gets a fresh set of state variables. However, the method implementations are shared among objects of the same class. Classes provide the benefit of reusability. Software programmers can use a class over and over again to create many objects.

Class Variables and Methods

In addition to the instance variables, it is also possible to define class variables, which are variables that belong to the whole class. This means that it has the same value for all the objects in the same class. They are also called static member variables.

Encapsulation

Encapsulation is the method of hiding certain elements of the implementation of a certain class. By placing a boundary around the properties and methods of our objects, we can prevent our programs from having side effects wherein programs have their variables changed in unexpected ways.

We can prevent access to our object's data by declaring them declaring them in a certain way such that we can control access to them. We will learn more about how Java implements encapsulation as we discuss more about classes.

Reference: Jedi Courseware

A simple C# program displaying "Hello world" on screen

By The Saint on Tuesday, January 06, 2009

comments (0)

Filed Under:

A simple C# program displaying "Hello World" on screen

The following console program stated below will simply display a string hello world on screen.


using System; //using keyword
used to import a library


namespace SampleCode{ //namespace denotes the project name

class HelloWorld{ //HelloWorld the name of the class
static void Main(string [] args){ //invoking the Main method

Console.WriteLine("Hello World"); //method used to display
the string
Hello world
}

}

}



fixed Single column page layout

By The Saint on Monday, January 05, 2009

comments (0)

Filed Under:

sSingle column css fixed layout

Here's a sample tutorial on how to create a single column css layout.
this layout includes a heading, content, 3 column adds and a footer. I also include a sample content for you to see the outcome of the layout.

This sample works on IE 6 and other compliant browsers.

---- CSS codes ----

body{
margin:0px 0px 0px 0px;
}
div.container {
margin:auto;
padding: 0px 0px 0px 0px;
}
div.topBackground{
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
background-color:#CC0000;
}
div.top{
width:1000px;
margin:auto;
padding:20px 0px 10px 0px;
font-family:Arial, Helvetica, sans-serif;
}
div.logo{
width:1000px;
margin:auto;
padding:0px;
}
div.image{
width:500px;
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
}
div.toplink{
float:right;
width:300px;
margin:0px 0px 0px 0px;
padding-top:0px;
padding-bottom:0px;
font-size:11px;
color:White;
}
div.menus{
clear:both;
width:1000px;
margin:auto;
background-color:black;
height:32px;
}
div.bannerad{
background-image:url('../img/banneradd.jpg');
width:1000px;
height:341px;
margin:auto;
padding:0px;
}
.clear{
clear:both;
margin:auto;
}
div.contentBackground{
margin:0px 0px 0px 0px;
padding:0px 0px 0px 0px;
background-color:#E0E1E1;
}
div.contents{
width:960px;
margin:auto;
padding:20px;
background-color:white;
}
div.otherlinks{
width:960px;
margin:auto;
padding:20px;
background-color:#DDBB99;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
}
div.footer{
width:960px;
height:25px;
margin:auto;
padding:20px;
background-color:black;
}
div.contentDownloads{
width:960px;
margin:auto;
padding:0px;
font-family:Arial, Helvetica, sans-serif;
}
div.contentDownloads div{
float:left;
margin:0px;
padding:0px;
width:320px;
}
div.contentDownloads div ul{
list-style-type:none;
padding:5px 0px 10px 5px;
margin:0;
font-size:small;
font-weight:bold;
}
div.contentDownloads div ul li{
width:280px;
padding:0px;
display:block;
margin:0;
font-size:small;
font-weight:normal;
text-align:left;
}


HTML code


<div class="container">
<div class="topBackground">
<div class="top">
<div class="logo">
<div class="toplink">Sign-in or Register</div>
<div class="image">
<img alt="" height="29" src="img/logo.jpg" width="136" /></div>
</div>
</div>
<div class="menus">
</div>
<div class="bannerad" >
</div>
</div>
<div class="contentBackground">
<div class="contents">
<div class="contentDownloads">
<div>
<ul>
<li>
<img alt="" src="sampleimage.jpeg" /></li>
<li>Download the trial version of FreeSoftware now and try it for yourself.
You'll be making gorgeous documents, presentations, and spreadsheets in
minutes.</li>
</ul>
</div>
<div>
<ul>
<li>
&nbsp;<img alt="" src="sampleimage.jpeg" /></li>
<li>Download the trial version of FreeSoftware now and try it for yourself.
You'll be making gorgeous documents, presentations, and spreadsheets in
minutes.</li>
</ul>
</div>
<div>
<ul>
<li>
&nbsp;<img alt="" src="sampleimage.jpeg" /></li>
<li>Download the trial version of FreeSoftware now and try it for yourself.
You'll be making gorgeous documents, presentations, and spreadsheets in
minutes.</li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>
<div class="otherlinks">Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum
iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum
dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
feugait nulla facilisi.</div>
<div class="footer"></div>
</div>
</div>


Simple CSS 2 column fixed webpage layout

By The Saint on Sunday, January 04, 2009

comments (0)

Filed Under:

2 column css fixed layout

Here's a sample tutorial on how to create a 2 column css layout.
this layout includes a heading, content, right nav and a footer. I also include a sample content for you to see the outcome of the layout.

This sample works on IE 6 and other compliant browsers.

--- CSS Codes ----

body{
margin: 0px;
}
.container{
width:990px;
margin:auto;
background-color:#EFEFEF;
border: 1px solid #CCCCFF;
padding:0px;
}
.top{
height:100px;
background-color:#CCCCFF;
}
.contents{
width:770px;
background-color:white;
text-align:left;
padding:5px 5px 5px 5px;
font-family:Arial, Helvetica, sans-serif;
font-size:small;
min-height:400px;
}
div.rightnav{
float:right;
width:195px;
padding: 5px 5px 5px 5px;
font-family:Arial, Helvetica, sans-serif;
margin:0px;
}
div.rightnav ul{
list-style-type:none;
padding:0;
margin:0;
font-size:medium;
font-weight:bold;
}
div.rightnav ul li{
margin-top:4px;
font-size:small;
font-weight:normal;
}
.rightnav ul li a{
display:block;
width: 175px;
padding: 3px 5px 3px 10px;
text-decoration: none;
color: #000;
}
.rightnav ul li a:hover{
color:black;
background-color:silver;
display:block;
}
.rightnav ul li:hover > ul{
background-color:silver;
display:block;
color:maroon;
position:relative;
}
.rightnav ul li ul{
display:none;
top:0px;
width:175px;
padding-left: 15px;
}
.footer{
clear:both;
height:50px;
background-color:#CCCCFF;
}


HTML Code


<div class="container">
<div class="top">Sample CSS Layout </div>
<div class="rightnav">
<ul>
<li>Top Downloads</li>
<li><a href="#">Menu 1</a></li>
<li><a href="#">Menu 2</a></li>
<li><a href="#">Menu 3</a></li>
</ul>
</div>
<div class="contents">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</div>
<div class="footer">Footer</div>
</div>