Abdullah Mamun

Ranch Hand
+ Follow
since Mar 19, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Abdullah Mamun

I am not clear how "E. The code is loosely coupled." is a correct answer.
I usually would like to execute each line and put the updated result beside the same line.
Below is an example in comment.
Not sure if it will help you.

1. method getArray() is called.
2. index variable set with value 2.
3. trying to fetch the value of 2nd index of the array that returned by getArray() method which is null and exception occurs.
Hi all,

I am new in Struts2 and creating a project using it.

I have created a login interceptor and its working fine when I forward to the specified action written in stuts.xml. But what I want is, after a successful login I will redirect the user where he wanted to go. e.g. if a user clicks on 'sell' he will be forced to log in and after login the 'sell' page should be shown. If he clicks on 'buy' the 'buy' page should be shown after login. Is there an elegant way to do this?

One thing I can do is, forward to a common JSP and fetch the requested URL saved in session or request then redirect to the requested page. But is there any other way?
17 years ago
Congratulations Adrian.

It took me a while too -- but I think the original poster thinks that the "&" operator somehow puts two bits together... meaning 1 & 1 ==> 11.



Thanks Henry, may be this could be the case.
But it would be better if we could know the poster's thought.
Why do you think the answer will be 00011011 ?

In this example the first loop will execute 2 times for i = 0 and i = 1
The second loop will execute 2 times too, for j = 0 and j = 1
Which means the

will execute 2*2 = 4 times for both loop.

Thats why the output is 0001.

Originally posted by Chandra Kota:

...How could the line # 3 resulted in true? What actually happened here? Did unboxing happened here or autoboxing? Which one would take priority? How to decide which one is going to happen? [banghead]...



In line #3 the Boolean b2 will unboxed to primitive boolean an then the check will happen. The priority is simple, when there is both wrapper and primitive present then the wrapper will unboxed...
int[][] a ={{1,2,},{3,4}};

First of all, Mind that in Java array is Object so it can be cast to Object as well. Now lets see what happens after the assignment...
a[0] = {1, 2}
a[1] = {3, 4}

int[] b = (int[]) a[1];//line 1
After this line...
b[0] = 3
b[1] = 4

Object o1 = a;//line2
Here the whole array is converted to Object as I said before

int[][] a2 = (int[][]) o1;//line3
Here again the object converted to the array. Its alright because the object is holding a two dimensional array of int

int[] b2 = (int[])o1;//line4
this line will give a runtime exception because you cannot cast a two dimensional array into a one dimensional array

System.out.println(b[1]);
This line will print 4

i thought String s="abc" is a short cut or alias of
String s=new String("abc") is that correct or not. Now i am getting confused .



Hi Srinivas

First statement is not alias nor shortcut of the second statement. Both has two different meaning which Ahmed Yehia already explained in the previous post.
Hi

You can also declare and initialize this array as follows

Originally posted by Praveen Seluka:

hi Al mamum

But in the example I gave,~ has higher precedance than increment operators,but still it executed last.WHY?



I think the reason is what I found in the JLS,

The Java programming language guarantees that every operand of an operator ( except the conditional operators &&, ||, and ? : ) appears to be fully evaluated before any part of the operation itself is performed.

If the binary operator is an integer division / or integer remainder %, then its execution may raise an ArithmeticException, but this exception is thrown only after both operands of the binary operator have been evaluated and only if these evaluations completed normally.



Also note that, postfix operator(expr++) has higher precedence than (~expr)

For further detail please follow this link
[ September 12, 2007: Message edited by: Al Mamun ]

Originally posted by Brandon Bay:

So does it means it always works from left to right, given that there's no parenthesis?



The operators always works according to the operator precedence not left to right always.
Note that, &(AND) has higher precedence than ^(XOR) which has higher precedence than |(OR)

You can test the statement using this code,

[ September 12, 2007: Message edited by: Al Mamun ]
I think your assumptions are correct.

trim() function returns a new String object if there are leading or trailing spaces, but return the same String object if there is no leading or trailing spaces.

For example, " string ".trim() --> Returns new String
"string".trim() --> Returns the same String
[ September 11, 2007: Message edited by: Al Mamun ]
Hi rex tony

Originally posted by :
...I'm getting the answer is String argument.
Why the Object argument doesn't excute the first, cause Object all for the base class.
What is reason...



The reason is, for an argument type, when more than one method is found as a candidate for calling then JVM chooses the most specific one and call that method. In this example, for null value, method with String and Object argument type are both candidate for calling. Since String is more specific than Object(i.e. String extends Object) so method with String argument gets called.