Lectures 4/5/6 – Types and Conditionals/Iteration and Arrays I/Iteration and Arrays II

Other 3 lectures from 61B course at Berkeley University….

Basically those are about instructions, loops and arrays in Java.

1:47 – very important “difference between references and primitive types – references point to an object somewhere” in other words, they do not own the data, “primitive are just simple basic types of data

so .. which are the primitive types in Java: byte, short, integer, long and for floating point numbers there are double and float and … boolean and char which can store only one single character.

it is almost sure that this guy, Jonathan, didn’t worked so much in the e,bedded filed, since he strongly recommends to use long, as a default data type.

11:41 maybe an interesting thing for those coming from a C++ background and wanting to learn Java – “in Java, unlike C++,” I think he should say C++, not C, since there is no boolean type in C, “you’re not allowed to mix boolean with integers

12:00 highly recommend to go through this comparison : primitive types and reference types

after this table is presented, some casts operations are also shown, all of them things which are quite trivial, so let’s jump to …
28:03 boolean – which can be created by some comparison operations (personally I didn’t know that !)

41:14 maybe one mistake concerning switch statement, which many beginner programmers do, consists in not inserting a break in switch‘s cases
you can hear about this also at 45:20

45:45 the return keyword … has to meanings: 1. causes a method to end when it is executes, returns the control to the calling code of the method
2. is the way (method) by which a function returns a value

Lecture 5 ….

loops … I think you are tired to hear about these, especially if you’re coming from a C or C++ background
I consider that I know those thing , so I won’t comment them, I will leave you the pleasure to enjoy them

15:50 … that’s the interesting part of this lecture Java arrays

16:30 in Java every array is an object also … an array can contain primitive and reference types

Remember the discussion about arrays in C? well in Java things are different from various reasons, one of them, probably the most important, is that Java does not support pointers and this generates all the differences

26:33 you can’t changed the length of an array, this is like in C

28:04 “when you define some class, can you make some fields read-only? the answer is NO” is he referring that there is no const in Java?

38:50 Multi-dimensional arrays .. a 2 dimensional array is an array of references to one dimensional array … just like in C/C++

Lecture 6:

1:26 Automatic array construction … what’s this? It is actually same thing explained in the last lecture, but the second dimension is given also, meaning the umber of columns. In the last columns it was specified just an array of references and each reference indicate a certain array with an unknown dimension. Here it is not the case anymore, at compile time both dimensions are specified, you define an array of X references, each of them indicating an array of Y elements, in other words you’re preventing the arrays pointed by the references to have different dimensions, forcing the matrix to be rectangle.

3:57 another way of creating arrays: Initializers

4:38 interesting to know that you can place as an element of an array an object created via by using a constructor

8:46 interesting to know how to declare arrays, be careful where you place the square brackets, really useful to know this …

10:28 when you create an array of objects, Java won’t create the objects for you – also very good to know

I will skip all the discussion concerning entry and exit point within a loop, because I think I am familiar with this stuff
It is important to note that Jonathan gives an example using main‘s parameter, which in Java is String [] args, it is not like in C, argc and argv

Another thing which is important to keep in mind is how break and continue statements act

31:00 it seems there is an interesting question about run-time errors – as exit points from a program

32:33 “one warning I want to give about break statement is that sometimes is easy to forget where exactly a break statement will jump to after it is executed

33:20 very interesting the example given with the AT&T programmer that introduced a bug into a phone switching network by making this specific mistake about break statement

33:58 “labeled break statement and labeled continue statement ” – wooow ! I didn’t know about that, Java slightly changed the meaning of break and continue

you can put a label in front of, virtually, any statement

37:10 continue applies only to loops

44:55 break works with both, switches and loops, continue works only with loops

45:20 constants… are defined with final keyword, you declare a value that cannot be changed again


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: