| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.

View
 

KjellChapterNotes

Page history last edited by PBworks 13 years, 6 months ago

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5


Chapter 6

UploadPrograms

http://dhsjava.pbwiki.com/f/Hello.java

http://dhsjava.pbwiki.com/f/Hello.class

Running the programs,

the way he shows it is a bit different from the way we are doing it in class.

Look for the errors when the file compiles, or doesn't. The pointer will show the error location, but the error is almost always 'ahead' 'above' or to the left of the pointer in the code. Look for misspelled words, typos, missing semicolons and stuff like that. It is usually easy stuff that breaks the code.

 

Neat program code

Write it neat so you can find the problems

use two spaces before the first indented bracket

 

Put the closing bracket on the same indentation, put it in at the same time as the first so you don't forget.

 

boxes within boxes.

Each set of brackets is its own block of code. Make sure you put only whole blocks inside other blocks. putting the brackets in as pairs helps avoid errors.

 

Capitalization is absolutely important in Java. Get it right, or you will have errors. Spelling is important as well, but sometimes is easier to spot than the capitalization errors.

 

The haiku is clever. Multiple lines of output.

Comments - // for one line

multiple line comments uses a / and a * . The star is on the inside of the comment.

/* comment for more than one line.

I guess you could use it for a single line, but why bother with the extra markup? */


Chapter 7

he is using notepad, which may not be productive. The dos editor has fewer things go break as far as the code.

 

Hitting control + or option and rolling the mouse wheel can make the text bigger in firefox. The bigger text makes it harder to mistake charactars.

 

The HelloPlanets code is useful to run, gives some experience in making code, and some compiling experience. Change the output so it does something different, a list of people, for example.


Chapter 8

In data there are primitive data types and objects. Any data type that you create is an object. The primitive data types are defined by the language.

When you create an object, it then creates a class in the compile process.

 

The data types are kind of difficult concepts, but they pretty much just have to be memorized/worked with until you get the hang of them.

The programming exercises are handy to get some real experience with them.

After coding the program as is, try changing the values of the numbers until you get the program to break. Then fix it so it works again.

Data Types are built in/primitive,

case sensitive, type it lower case and it just works

different from objects, which are data types that you invent

objects are called classes

 

Each of the data types takes up a quantity of memory measured in bytes. this is kind of like having a lot of memory car parking spaces, and you can park up to the maximum amount of cars in it. If you have a bigger number of digits, you may go over the capacity of the parking spaces.

 

Byte has 8 bits of memory, short uses 16 bits of memory, int uses 32 bits of memory, long uses 64 bits of memory, float uses 32 bits of memory and double uses 64 bits of memory

 

http://chortle.ccsu.edu/CS151/Notes/chap08/ch08_6.html

 

How much memory/how many bits the data takes is driven by which data type you use.

Integer primitive data types
byte 8 bit - 128 to + 127
short 16 bits-32,768 to + 32,767
int 32 bits-2 billion to + 2 billion
long 64 bits-10E18 to +10E18
Floating point primitive data types
float 32-3.4E+38 to +3.4E+38
double 64-1.7E+308 to 1.7E+308

 

char 16 bita single unicode charactar
boolean true false

 

Wrapper classes


Chapter 9A - Variables and Assignment statements

machine instructions and data use the same memory - Jon von Neumann

programming style - variables are spelled with cap in middle payAmount

 

variable can't be used unless it is declared. It can only be declared once.

 

names for variables -

a-z 0-9 and $ no spaces

can't start with a digit

can't use a reserved word

can't be in use in this part of the program

 

in the javascript simulator, it won't work if you put a decimal in the number.

 

Code your programs so they look clean on the screen. Use spaces to place the info in a way that is easy to debug. Spaces mean nothing to the compiler, but they mean a lot to the human being reading, editing and making the code.

 

Assignment statement syntax

http://chortle.ccsu.edu/CS151/Notes/chap09/ch09_11.html

two steps, calculate, then place the answer in the variable sum

 

Arithmetic operators

there is a priority level for each of the operators

high, middle low - http://chortle.ccsu.edu/CS151/Notes/chap09/ch09_14.html#operators,%20table%20of

the high priority ones get done first, middle next etc

unary minus and unary plus are negative or positive numbers, which are high priority.

multiplication, division and remainder are middle priority.

addition and subtraction are low priority.

 

putting things in parenthesis can change the order

http://chortle.ccsu.edu/CS151/Notes/chap09/ch09_14.html

Sequence goes from left to right, high priority to low priority

There is a way of notating the equations to illustrate the sequence by hand

http://chortle.ccsu.edu/CS151/Notes/chap09/ch09_16.html

 

Sample programs

 

http://chortle.ccsu.edu/CS151/Notes/chap09/ch09_7.html

In the pay stub example, can you get the numbers to all line up vertically? What do you need to do? If there is a problem, what is causing it?

Give yourself a raise. What happens?

If you have a real paystub, check your numbers against the example.

Can you get it to give accurate results that match your stub?

 

How do you get the variables to declare themselves?


Chapter 9B

Expression - a combination of literals, operators, variable names and parentheses used to make a calculation

the rules of java expression are similar to algebra

operator - +-/*

operand - value acted upon by the operator

Comments (0)

You don't have permission to comment on this page.