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 01:22 am (UTC)
From: [identity profile] http://users.livejournal.com/jer_/
Yeah, I was always just taught the order... and yes, the 0th rule of programming is that programmers count from 0.

Date: 2009-01-15 02:19 am (UTC)
From: [identity profile] zimzat.livejournal.com
Unless you're in VB, in which case you have to explicitly tell it to count from zero. Whee. (I still remember those pre-.NET days, heh)

Also, MySQL counts from 1 when doing str positioning and what-not. >_>

July 2025

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

Most Popular Tags