Ashwin Raju

Greenhorn
+ Follow
since Oct 27, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ashwin Raju



I was writing code to switch 2 pairs of strings using arraylist. I finally got the program to run but I am not able to understand the way this get() method works.

l.add(i,l.get(i+1)) ---> This code should add the next element(i+i) to the previous index value(i) but it skips ahead(jumps to the 3rd index value instead of the 2nd) and does not print the desired answer.

ANSWER WHEN I RUN ABOVE CODE:
Enter a text value:
Hi how are you today
[are, Hi, today, are, today]

l.add(i,l.get(i)) ----> This code gets the next value(get(i)) and adds that to the previous index value. HOW IS THIS HAPPENING?

ANSWER WHEN I RUN ABOVE CODE:
Enter a text value:
Hi how are you today
[how, Hi, you, are, today] ---> this is the right answer FYI
5 years ago
OK ..so it's about how you can access it. So lets imagine that we live in a world where "static" did not exist. So you could still use "final" but accessing it would be a little more tedious.correct?
6 years ago
public static final String NAME="JAVATAR";

"final" makes sure the constant has the same value and prevents it from being changed. So why add "static" to make it a constant. I figured the reason a few weeks back but don't remember it now.. Can somebody explain it in a way I can remember it really well..
6 years ago
I love JAVA... I am the JAVATAR!!!