Thursday, February 7, 2013

References and Primitive Data Types

References and Primitive Data Types:


Java distinguishes two kinds of entities
Primitive types
Objects
Primitive-type data is stored in primitive-type variables
Reference variables store the address of an object
No notion of “object (physically) in the stack”
No notion of “object (physically) within an object”

Primitive Data Types:
Represent numbers, characters, boolean values
Integers: byte, short, int, and long
Real numbers: float and double
Characters: char

A Little Example of import and main:

A Little Example of import and main:

import javax.swing.*;    // all classes from javax.swing public class HelloWorld// starts a class  public static void main (String[] args) {  // starts a main method  // in: array of String; out: none (void)  }}public = can be seen from any packagestatic = not “part of” an object

Processing and Running HelloWorld:

javac HelloWorld.java
Produces HelloWorld.class (byte code)
java HelloWorld
Starts the JVM and runs the main method.

Classes and Objects:

Classes and Objects:

The class is the unit of programming
A Java program is a collection of classes
Each class definition (usually) in its own .java file
The file name must match the class name
A class describes objects (instances)
Describes their common characteristics: is a blueprint
Thus all the instances have these same characteristics
These characteristics are:
Data fields for each object
Methods (operations) that do work on the objects

Grouping Classes: The Java API,

API = Application Programming Interface
Java = small core + extensive collection of packages
A package consists of some related Java classes:
Swing: a GUI (graphical user interface) package
AWT: Application Window Toolkit (more GUI)
util: utility data structures (important to CS 187!)
The import statement tells the compiler to make available classes and methods of another package
A main method indicates where to begin executing a class (if it is designed to be run as a program)


Java Processing and Execution

chapter:2

Java Processing and Execution:

Begin with Java source code in text files: Model.java
A Java source code compiler produces Java byte code
Outputs one file per class: Model.class
May be standalone or part of an IDE
A Java Virtual Machine loads and executes class files
May compile them to native code (e.g., x86) internally

Compiling and Executing a Java Program:





Intro to java

      Introduction to Java

Topics of the Review:

Essentials of object-oriented programming, in Java
Java primitive data types, control structures, and arrays
Using some predefined classes:
Math
JOptionPane, I/O streams
String, StringBuffer, StringBuilder
StringTokenizer
Writing and documenting your own Java classes

Some Salient Characteristics of Java:

Java is platform independent: the same program can run on any correctly implemented Java system
Java is object-oriented:
Structured in terms of classes, which group data with operations on that data
Can construct new classes by extending existing ones
Java designed as
A core language plus
A rich collection of commonly available packages
Java can be embedded in Web pages

Wednesday, October 24, 2012

CSS Sheats


Chapter 8


Multiple Style Sheets

If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet. 
For example, an external style sheet has these properties for the h3 selector:
h3
{
color:red;
text-align:left;
font-size:8pt;
}
And an internal style sheet has these properties for the h3 selector:
h3
{
text-align:right;
font-size:20pt;
}
If the page with the internal style sheet also links to the external style sheet the properties for h3 will be:
color:red;
text-align:right;
font-size:20pt;
The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet.

Multiple Styles Will Cascade into One

Styles can be specified:
  • inside an HTML element
  • inside the head section of an HTML page
  • in an external CSS file
Tip: Even multiple external style sheets can be referenced inside a single HTML document.

Cascading order

What style will be used when there is more than one style specified for an HTML element?
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority:
1.    Browser default
2.    External style sheet
3.    Internal style sheet (in the head section)
4.    Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style defined inside the <head> tag, or in an external style sheet, or in a browser (a default value).

CSS Sheats



Chapter 7

Three Ways to Insert CSS
There are three ways of inserting a style sheet:
  • External style sheet
  • Internal style sheet
  • Inline style

External Style Sheet
An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section:

E-g:

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
Internal Style Sheet
An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, by using the <style> tag, like this:

E-g:

<head>
<style>
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
</style>
</head>


Inline Styles
An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly!
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph:

E-g:

<p style="color:sienna;margin-left:20px">This is a paragraph.</p>