Balaji Sampath

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

Recent posts by Balaji Sampath

Hello Ranchers
For the following code below do we need to close the filewriter object in finally block even when i close BufferedWriter Object.


private void appendFile(String fileName) throws IOException{
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(fileName, true));
String textToFile= "Hello";
bw.write(textToFile);
bw.newLine();
bw.flush();
} catch (IOException ioe) {
throw ioe;

} finally { // close the file
if (bw != null)try {
bw.close();

} catch (IOException ioe2) {
throw ioe2;
}
} // end try/catch/finally





}
Suppose you call this method from say a class giving fileName has the input parameter the programs works fine but Occasionally it says Input file opened lot of resources .
So was not sure if i do need to close the filewriter instance opened..
18 years ago
The basic concept is , when you declare the inner or local variable that has the same name has the class or instance variable then the inner variable shadows the outer variable. This concept is called shadowing of variables.

Thanks
Balaji.S

I'm trying to use form at this point for storing data as type hidden and then do form.submit(). Is there a better way of doing this?




IM not sure if you have come acros the new technology "AJAX"..
http://www.adaptivepath.com/publications/essays/archives/000385.php

Just have a look and let me know if that was of any help??
18 years ago
JSP
hope this sample code will help your understanding!!!




And the output is as follows:

Index equals String Length: -1
Index greater than String Length: -1
Index is negative: 5



Thanks
Balaji.S
Jones,
I try to detail the above code below and let me know if at any chance it clarified.



Then under the same package have class A:



Now when u try to compile the class A and run it it did print the statement in the default constructor: In the constructor ClassB()

Since the classes marked public can be accesed from anywhere!!

If you try introduce a compile time error in class B and run class A it throws exception.
So im not sure what exactly ur looking in this question.

Thanks
Balaji.S
Hi there
When i happen to run the following code i got the output has

Intial value----> 0

Final Value ---->343




Let me know if this is what u need..

Thanks
Balaji.S
If u change the method1() in parents class like:

then the output would be
Parents method2()
Child method1()


Thanks
Balaji.S
In for SCJP 1.5.. Probable date july 10th
They do give one easy erase board or a rough paper for ur work.

Thanks
Balaji.S
Let me try to rephrase the question in this way:



From the above code the first constructor to be called would be the default constructor StringCreation() .

I beleive thats the explanation u require?

Anywayz please to brief me if u need any further detail regarding the above code.

Thanks
Balaji.S
Doesnt the overriden method ned tohave access modifier more than the supeclass method???

Thanks
Balaji.S
It depends on the platform . For those who are taking SCJP 5.0 the above code compiles fine and the result would be 19,11.
Hi tim
It would be a better understanding if you can post the question.(especially for those who dont hvae the book..)

Balaji