Getting “unixtime” in Java

Avoid the Date object creation w/ System.currentTimeMillis(). A divide by 1000 gets you to Unix epoch. As mentioned in a comment, you typically want a primitive long (lower-case-l long) not a boxed object long (capital-L Long) for the unixTime variable’s type.

How to really read text file from classpath in Java

With the directory on the classpath, from a class loaded by the same classloader, you should be able to use either of: If those aren’t working, that suggests something else is wrong. So for example, take this code: And this directory structure: And then (using the Unix path separator as I’m on a Linux box): … Read more

Why is Netbeans suggesting I “Flip operands of the binary operators” in my Java code

Netbeans frequently suggests that I “flip operands of the binary operator” when I’m doing mathematical calculations. For example, in the following line of code: Netbeans makes the suggestion for every mathematical symbol (so it does it three times in the ‘pennies’ line. I’m not sure I understand why it’s making the suggestion. If I were … Read more

Printing array elements with a for loop

This is a challenge question from my online textbook I can only get the numbers to prin forward… 🙁 Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)