srinadh penugonda

Greenhorn
+ Follow
since Feb 13, 2007
Merit badge: grant badges
For More
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 srinadh penugonda

Thanks
You guys have really been of great help!!!
Much appreciated.
- a java beginner
15 years ago
That is also my dilemma. How to test this? How to put newline char in a test string???
15 years ago
Hi java experts,
If I use trim() on a string that might contain newline char, will it be removed?
From the documentation, it says trim() removes leading and trailing whitespaces.
At the same time, I see this:
A character is a Java whitespace character if and only if it satisfies one of the following criteria:
It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0', '\u2007', '\u202F').
It is '\u0009', HORIZONTAL TABULATION.
It is '\u000A', LINE FEED.
It is '\u000B', VERTICAL TABULATION.
It is '\u000C', FORM FEED.
It is '\u000D', CARRIAGE RETURN.
It is '\u001C', FILE SEPARATOR.
It is '\u001D', GROUP SEPARATOR.
It is '\u001E', RECORD SEPARATOR.
It is '\u001F', UNIT SEPARATOR.

So, if I assume trim() removes any of the above characters, is my assumption right?
15 years ago
Congratulations.
Thats wonderful score!
[ January 10, 2008: Message edited by: srinadh penugonda ]
16 years ago
Congratulations.
Thats wonderful score!
[ January 10, 2008: Message edited by: srinadh penugonda ]
Thanks Henry. That was really helpful.

So how do I avoid the name array being changed by classes outside to my Person class?

One option could be create private String instance members; and no one can change them outside of the Person class. But I guess this is what can be called a lousy solution..
One more interesting thing is if I define private int in Person and try to do the same as name, it doesnt behave the same way - "works as expected".
class Person {
private int i;

public int getNum() {
return i;
}

public Person() {
i = 9;
}
}

public class Demo{
public static void main(String[] args) {
Person p= new Person();
int j = p.getNum();
j = 0;
System.out.println(p.getNum());
}
}

It gives 9 as expected.

May be in the case of String[], we got reference and we can make merry out of it.
[ January 02, 2008: Message edited by: srinadh penugonda ]
Hi Srilatha,
Nice find. I couldnt understand either. I got the same result. I could modify the private String array name defined in Person from Demo...

Alejandro, you said " if you already have a String in the pool, and you intent to create a new instance variable of that String, the JVM don't create a new String, it just make your new variable to reference to the existing String".
But it is the case only when we try to initialize the another String instance variable with same value as existing one.
like this:
String s1 = "Hello";
String s2 = "Hello";

In this case, JVM doesnt create a new string object but returns reference to existing s1.

In Srilatha's example, she initialized with different values.

Still, it doesnt answer how come you are able to modify a "private" string array from another class???
[ January 02, 2008: Message edited by: srinadh penugonda ]
Wow!.
Thanks Raghavan for the nice explanation.
And Apratim, for bringing an easy-to-miss subtlety of static members to everyone's attention.. I myself thought it would threw NullPointerException.

[ January 01, 2008: Message edited by: srinadh penugonda ]
[ January 01, 2008: Message edited by: srinadh penugonda ]
I need to transfer the date in 'yyyymmdd hh.mm.ss' format to "Tue Jun 12 13:54:42 EDT 2007" format.

I have the following code:
private String formatTimeStamp(String timeStamp) {
StringBuffer tempDate = new StringBuffer();
int year;
int day;
int month;
int hour;
int minute;
int second;

tempDate.append(timeStamp);
year = Integer.parseInt(tempDate.substring(0, 4));
month = Integer.parseInt(tempDate.substring(4, 6));
day = Integer.parseInt(tempDate.substring(6, 8));
hour = Integer.parseInt(tempDate.substring(9, 11));
minute = Integer.parseInt(tempDate.substring(12, 14));
second = Integer.parseInt(tempDate.substring(15, 17));

return (new Date((year-1900), (month-1), day, hour, minute, second).toString());
}

However, this gives date as: Tue Jun 12 13:54:42 EST 2007

Is there something I should initialize or follow different way to code?
Thanks in advance.
16 years ago
Hi All,
I have logout action mapping as follows in my struts-config.xml:
<action
path="/Logout"

type="com.xxx.yy.dd.mm.web.action.LogoutAction">
<forward name="success" path="/index.jsp"/>
<forward name="failure" path="/LogoutFailed.jsp"/>
</action>
My problem is I now have to invoke a web page (www.google.com) instead of login page.. Can someone enlighten me a novice in struts.. Much appreciated.
16 years ago
Bear Bibeault
Appreciate the reply..
Can you please tell me how else can I achieve it ... I am just learning the tricks so any pointers/examples would be of great help.
Thanks again.
16 years ago
<div id="sidebar">
<logic:present name="userVO">
<logic:iterate id="element" name="userVO" property="features" indexId="i">
<a href="<bean:write name="userVO" property='<%= "featuresLinks["+ i +"]" %>' />" class="sidebar"> <html:image src="<bean:write name="userVO" property='<%= "imagePaths["+ i +"]" %>' />"/> </a>
</logic:iterate>
</logic:present>
<version data="11.01.04svp1"><sysinfo data=""></sysinfo></version>
</div>

I am trying to place a link with an image. However, I am getting run-time exception that says "equal symbol expected" in the expression.. It points to 'O' in userVO in the image:src
I am totally lost on why I am getting this error.. and any help/pointers in this regard will be much appreciated.
Thanks
16 years ago