Java notes

Jan. 14th, 2009 04:56 pm
nemorathwald: (Default)
[personal profile] nemorathwald
Halfway break in Java class.

Everyone was surprised that I was never taught in second grade "Please Excuse My Dear Aunt Sally". First you resolve parentheses and exponents, second you resolve multiplication and division operators, third you resolve addition and subtraction operators. However, Java doesn't have the exponent operator and it does have a remainder operator, so I decided it's "Prosecute My Dirty Rotten Aunt Sally".

It's counter-intuitive for me to do integer arithmetic, in which every step, Java gets rid of the fraction. 7/2=3

It takes me a long time to perform basic arithmetic in my head, on the best of days.

String fullname;
fullname = "John Kennedy"
secondLetter = fullname.charAt(1);

It returns 'o' not 'J' because everything counts from 0. Zero is always the first number. 1 is the second number.

age = age -3; // same as age -= 3;

Today's flashcard:

In an expression, what is the difference between variable++ and ++variable?
With x++ Java waits to resolve the rest of the expression before incrementing x by 1.

Date: 2009-01-15 03:08 pm (UTC)
From: [identity profile] loop-bell.livejournal.com
"Programmers count from zero" -- except when they don't. Matlab used to give me headaches because it starts from 1, among other reasons.

But that's getting less common these days with the rise of the so called "curly bracket languages" that tend to build on BCPL conventions for counting as well as syntax.


July 2025

S M T W T F S
  12345
6 789101112
13141516171819
20212223242526
2728293031  

Most Popular Tags