Encrypt Password in Configuration Files?

A simple way of doing this is to use Password Based Encryption in Java. This allows you to encrypt and decrypt a text by using a password. This basically means initializing a javax.crypto.Cipher with algorithm “AES/CBC/PKCS5Padding” and getting a key from javax.crypto.SecretKeyFactory with the “PBKDF2WithHmacSHA512” algorithm. Here is a code example (updated to replace the … Read more

Variable might not have been initialized error

You declared them, but you didn’t initialize them. Initializing them is setting them equal to a value: You get the error because you haven’t initialized the variables, but you increment them (e.g., a++) in the for loop. Java primitives have default values but as one user commented below Their default value is zero when declared … Read more

Cannot instantiate the type Queue. Why is this?

This is my main method for a stacks/queues assignment. I keep getting an error with my queue, but not my Stack. The stack class seems to be working just fine. I’m completely stuck. It says “cannot instantiate type Queue”. Any help would be most appreciated!

Is not an enclosing class Java

ZShape is not static so it requires an instance of the outer class. The simplest solution is to make ZShape and any nested class static if you can. I would also make any fields final or static final that you can as well.

align text center with android

Set also android:gravity parameter in TextView to center. For testing the effects of different layout parameters I recommend to use different background color for every element, so you can see how your layout changes with parameters like gravity, layout_gravity or others.

TreeMap sort by value

You can’t have the TreeMap itself sort on the values, since that defies the SortedMap specification: A Map that further provides a total ordering on its keys. However, using an external collection, you can always sort Map.entrySet() however you wish, either by keys, values, or even a combination(!!) of the two. Here’s a generic method … Read more

Double cannot be dereferenced?

EDIT 4/23/12 double cannot be dereferenced is the error some Java compilers give when you try to call a method on a primitive. It seems to me double has no such method would be more helpful, but what do I know. From your code, it seems you think you can copy a text representation of … Read more

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