In Php, I really often use this one:
$conn_sets = array();
$conn_sets['login'] = "aaa";
$conn_sets['pass'] = "bbb";
How to do the same in JAVA 1.6. I tried to do this:
private method1() {
String[] mystring = new String[] {"login" => "aaa", "pass" => "bbb"};
}
But that gives me an error. I want to make this work because I have error list declarations, and it’s better to define:
throw new MyException(myerrors['failed_login_error']);
than a:
throw new MyException(myerrors[116]);
I know that I can make a new class and throw away the object:
throw new MyException(ERROR_CONSTANTS.FAILED_LOGIN_ERROR);
But I prefer the first (same as in Php).
So any ideas?
source
share