LS> Hi all...

LS> I have piece of code like this..

LS>   char charArray[] = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a','y'};
LS>   byte byteArray[] = { (byte) 'n', (byte) 'e', (byte) 'w',
LS>          (byte) ' ', (byte) 'y', (byte) 'e',
LS>          (byte) 'a', (byte) 'r' };
LS>   StringBuffer buffer;
LS>   String s, s1, s2, s3, s4, s5, s6, s7, output;

LS>   s = new String( "hello" );
LS>   buffer =
LS>    new StringBuffer( "Welcome to Java Programming" );
LS>   // use the String constructor
LS>   s1 = new String();
LS>   s2 = new String( s );
LS>   s3 = new String( charArray );
LS>   try {
LS>    s4 = new String( charArray, 6, 4 );
LS>   }
LS>   catch( StringIndexOutOfBoundsException ex ) {
LS>    System.out.println( "out of exception" );
LS>   }
LS>   s5 = new String( byteArray, 4, 4 );
LS>   s6 = new String( byteArray );
LS>   s7 = new String( buffer );


LS>   output = "s1 = " + s1 +
LS>     "\ns2 = " + s2 +
LS>     "\ns3 = " + s3 +
LS>     "\ns4 = " + s4 +
LS>     "\ns5 = " + s5 +
LS>     "\ns6 = " + s6 +
LS>     "\ns7 = " + s7;

LS> When i try to compile this, an error "variable s4 might not have been
LS> initialized" occurs.

In case of exception your s4 object is not initialized, and after
exception handling the code continues to run. You should either
initialize your s4 before the try block ( for instance to null) or
make return in your catch block.

LS> Would someone like to explain me why?

LS> Thankyou in advance.

LS> ::Lambok Sianturi::
LS> PT. Multi Garmenjaya
LS> Jl. Krawang No. 1
LS> Bandung - Jawa Barat
LS> Indonesia
LS> Phone : 62 22 7272222
LS> ----- Original Message -----
LS> From: "abhay" <[EMAIL PROTECTED]>
LS> To: "JDJList" <[EMAIL PROTECTED]>
LS> Sent: Wednesday, January 22, 2003 9:45 PM
LS> Subject: [jdjlist] jar updation prob.


LS> | Hi everybody,
LS> |
LS> | I'm using WSAD-5 for application developement. I dynamically create a
LS> | jar file (say AAA.jar ) and
LS> | want to update it frequently in our application. I also use this jar
LS> | file in our classpath of application.
LS> | This jar is supposed to contain all the property files needed for our
LS> | application. Initially AAA.jar will
LS> | contain some property files. As the transactions initiate, property
LS> | files in this jar will be changed and
LS> | updated.
LS> |
LS> | I create a jar file by using a ZipOutputStream, store it in my
LS> | ../../temp folder by some xx.0456.tmp
LS> | file name. Then I delete the existing jar file using file.delete() and
LS> | then rename the temp file by invoking
LS> | the file.renameTo() method. But i found that the file.delete() doesn't
LS> | delete my original jar file (which is
LS> | being used by our application).
LS> |
LS> | Even invoking the SecurityManager.checkDelete() method didnot throw  any
LS> | exception (as the
LS> | docs say) . I think that since AAA.jar is being used by our application
LS> | ... WSAD must have
LS> | locked it. (Another reason for this conclsion is that i cannot modify
LS> | any of our jars manually while the
LS> | application is running under WSAD). But if this is true then
LS> | SecurityManager should have thrown an
LS> | exception ...surprisingly ..it didn't.
LS> |
LS> | I'm a little confused ...If i'm logically correct .. please suggest me a
LS> | solution or a workaround.
LS> | If i'm not then please tell me  where am i wrong.
LS> |
LS> | Thanks in advance.
LS> |
LS> | regards
LS> | abhay
LS> |
LS> |
LS> |
LS> | ____________________________________________________
LS> | To change your JDJList options, please visit:
LS> | http://www.sys-con.com/java/list.cfm
LS> |
LS> | Be respectful! Clean up your posts before replying
LS> | ____________________________________________________
LS> |
LS> |
LS> |



LS> ____________________________________________________
LS> To change your JDJList options, please visit:
LS> http://www.sys-con.com/java/list.cfm

LS> Be respectful! Clean up your posts before replying
LS> ____________________________________________________


____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

Be respectful! Clean up your posts before replying
____________________________________________________

Reply via email to