Possible to initialize a String as empty?

So, in the following code i initialize result with null because i want it to be empty. However when i run the driver for the method, i get the first proper character followed by null for output. For instance "snull" is my output. Any ideas why this is occuring? public class Cipher {
String words;
String result;
String enc;
String ke;
String mes;     
public Cipher(String en, String k, String me) {
     words = null;
     result = null;
     enc = en;
     ke = k;
     mes = me;
public String encipher(String encode, String key, String message) {
if (message.length() > 0 && message.charAt(0) == encode.charAt(0)) {
     String temp;
     temp = (key.charAt(0) + this.encipher(encode, key, message.substring(1, message.length())));
     this.result = temp;
     else if(message.length() > 0 && encode.length() > 1 && key.length() > 1) {
     this.encipher(encode.substring(1, encode.length()), key.substring(1, key.length()), message);
     return this.result;
}

String s = ""; // empty string

Similar Messages

  • What is difference between Null String and Empty String ?

    Hi
    Just i have little confusion that the difference bet'n NULL String and Empty String ..
    Please clear my doubte.
    Thankx

    For the same reason I think it's okay to say "null
    String" and "empty String "as long as you know they
    really mean "null String reference" and "empty String
    object" respectively. Crap. It's only okay to say that as long as *the one you're talking to" knows what it really means. Whether you know it or not is absolutely irrelevant. And there is hardly any ambiguity about the effects that a statement like "assign an object to a reference" brings. "Null String" differs in that way.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Is it possible to pass a string from an applet to the web site?

    Hi, everybody!
    Is it possible to pass a String from an applet to a web site (as a field value in a form, an ASP variable, or anything else). Basically, I have a pretty large String that is being edited by an applet. When a user clicks on the submit button, a different page will show up which has to display the modified string. The String is pretty large so it doesn't fit into the URL variable.
    Please, help!
    Thank you so much!

    Why do you want to do this in Java?
    Javascript is the correct language for these type of situations.
    for instance:
    in the head of your html document:
    <script language=javascript type="text/javascript">
    createWindow(form){
    if(form.text.value!=""){
    newDoc = new document
    newDoc.write(form.text.value)
    newWin = window.open(document,'newWin','width=200;height=150')
    </script>
    in the body:
    <form onSubmit="createWindow(this)">
    <p>
    Enter a String:<input type=text size=30 name="text">
    </p><p>
    <input type=submit value="submit"> 
    <input type=reset value="reset">
    </p>
    </form>

  • Is it possible to add a string inside a textbox with a value of another textbox for Acrobat Forms?

    Is it possible to add a string inside a textbox with a value of another textbox?
    ex.
    Textbox1 = Happy
    Textbox2 = Sad
    Textbox3 = "I am Happy therefore I am not Sad"
    "I am (value of textbox1) therefore I am not ( value of textbox2)"

    Use this code as the custom calculation code of Textbox3:
    event.value = "I am " + getField("textbox1").value + " therefore I am not " + getField("textbox2").value;
    Notice that the field names are case-sensitive.

  • Is it possible to pass a string representing a class name in java as an arg

    Hi, this is probably a bit of a stupid question, but one that has me quite confused all the same!
    Is it possible to pass a string or class name etc. representing a type of class in java, to a method so that instead of having to redefine a method with say the following args:
    public SolarPanels[] bestPVPanels(int budget, int percent) {
            HashMap<Integer, SolarPanels> panelsMap    = new HashMap<Integer, SolarPanels>();
    }As at present needing to create a methods bestWindTurbine() and many others exactly the same, but for the type, I would instead like to be able to create a method like:
    public Object[] bestRenewable(int budget, int percent, String aClassName) {
            HashMap<Integer, aClassName > renewableMap    = new HashMap<Integer, aClassName >();
    }But cant sus how to do this as passing a String is off course going to cause problems unless its it possible to cast a string to a class name, any help or advance would be much appreciated.
    Thanks in advance
    Pat Nevin

    pNev wrote:
    But cant sus how to do this as passing a String is off course going to cause problems unless its it possible to cast a string to a class nameIt's not. You can do things like
    Class.forName(classNameInString);But that will only return a Class object.
    And as Java generics are erased at runtime, passing the class name to the method is useless as it is too late to use it anyways.
    Ah, Peter's way is what I was thinking of. Too early in the morning.
    Edited by: Kayaman on 23.6.2010 10:02

  • Is it possible to append a string on canvas without calling repaint() ??

    Hi..experts
    I am new to J2ME programming. i want to append characters on canvas one by one.
    is it possible to append a string to another that is allready drawn without repainting all canvas.
    please help me.
    Thanks a lot

    without repainting all canvas.if your not comfortable repainting the entire canvas, You can use the selective repaint function. it repaints only the area specified by you
    repaint(int x, int y, int width, int height)
    //Requests a repaint for the specified region(x,y) of the Canvas.ps: selective repainting is the VM's decision

  • Message received when openning the  Adobe Premiere Elements 12 "Not possible to initialize on-line services" What do I have to do?

    Hello,
    How can I fix this problem?
    Message received when openning the  Adobe Premiere Elements 12 "Not possible to initialize on-line services" What do I have to do?
    Thanks in advence,
    FL

    FLOureiro
    What computer operating system is your Premiere Elements 12 running on? Have you updated 12 to 12.1 Update using an opened project's Help Menu/Update? If not, please do so.
    For your immediate issue, have you update the Online Services in preferences?
    Where are you in the program when you get the message "Not possible to initialize on-line services".
    Are you in a country outside of the USA?
    There certain online services that are just not available outside the USA.
    Please review and consider and then, based on your details, we will consider what next.
    Thank you.
    ATR

  • Is it possible to initialize bindings programatically?

    I'm trying to access the bindings from another page different from the current one, but it seems like they been not initialized, I'm a little confused. Is it possible to initialize them programatically from a backing bean?
    I'm working with JSF , EJB (session, as a facade) , and TopLink.

    Actually I solved the problem by referencing the other bindings like this :
    "#{data.SomeNonCurrentBindingContainer.SomeBindingName} in the component's value property. However I found an article of your own about this, called
    "References to Bindings in Non-Current BindingContainer Require Changes After Migration"
    You write:....If you reference bindings like ${data.SomeBindingContainer.SomeBindingName} in "shared" JSP page fragments that you include into multiple pages then you can programmatically prepare the SomeBindingContainer during the current page request by overriding the prepareModel() ......
    Is it there any article that explain this in a little more detail, I mean a more complete example. The situation fits exactly with my problem
    Thanks for your answer....

  • Is it possible to receive a String[] back into stored procedure?

    Hi,
    Is it possible to return String [] into plsql procedure?
    I have a class :
    class CreditCard {
    public static String cc (String args []) []
    throws
    SQLException, ClassNotFoundException
    I load it into the database and then create a plsql procedure:
    CREATE OR REPLACE PROCEDURE check_credit(
    card_number IN          VARCHAR2,
    exp_month IN          VARCHAR2,
    exp_year      IN          VARCHAR2,
    flag1      OUT varchar2,
    flag2          OUT varchar2)
    AS LANGUAGE JAVA
    NAME 'CreditCard.cc(java.lang.String[]) return java.lang.String[]';
    trying to compile it gives me:
    20/1 PLS-00311: the declaration of "CreditCard.cc(java.lang.String[])
    return java.lang.String[]" is incomplete or malformed
    Is it possible to receive a String[] back into stored procedure?
    Thanks
    Leonid

    I don't think you can use a String Array directly, you have to use an oracle.sql.ARRAY.
    You use the oracle.sql.ARRAY parameter in Java as an OUT parameter in the stored procedure. You need to use an ArrayDescriptor which requires a corresponding Oracle Nested Table type.
    Try something like the following:
    First the Nested Table Type:
         CREATE OR REPLACE TYPE
         TBL_STRINGS AS TABLE OF VARCHAR2(999);
    Then the Java method:
    public static void getStrings(oracle.sql.ARRAY[] theStrings) //has to be an array of oracle.sql.ARRAY's as we use it as an OUT parameter
    try
         //get a connection
         Connection conn = DriverManager.getConnection("jdbc:default:connection:");
         String [] colours = new String []{"RED", "GREEN", "GOLD"};
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor("TBL_STRINGS", conn);
    theStrings[0] = new oracle.sql.ARRAY(desc, conn, colours);
         conn.close();
    catch (SQLException sqle)
              //report error
    Then the call spec:
         PROCEDURE GET_STRINGS(p_the_strings     OUT     TBL_STRINGS)
         AS LANGUAGE JAVA
         NAME 'mypackage.MyClass.getStrings(oracle.sql.ARRAY[])';

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • Initialize a string to null or ""

    String s;
    When we declare a variable with type String, we need to initialize it. Or we will get compile error "variable s might not have been initialized"
    My question is which way we should do?
    1) String s = null;
    2) String s = "";
    Or it really depends on our application needs?

    In Java, the null reference is a value that indicates that the reference does not point to an object. You have to decide what semantics to give that value. If you want null to indicate that the value hasn't been set, you need an object to indicate that the value has been set to "blank".
    In the case of a String, you could make a special String object:
    public final BLANK_VALUE = new String();
    and then use == to test for this object. Often, however, the empty String "" is used to indicate the value has been set to "blank".
    But let me also state that if you are only trying to avoid "variable might not have been initialized" then you are basically not coding the right way
    e.g
    String s;
    if (true)
    s="VOW";
    }this way you would get the error but then in this case rather than initializing and then putting in another value later a better practice would be
    String s;
    if (true)
    s="VOW";
    else
    s="HELP"; //now you wouldnot get the error.

  • Difference between null string and empty string??

    what is the major difference between null string and an empty string??
    I wrote the following simple program and I could see some different output.
    Other than that, any other differences that we should pay attention to???
    C:\>java TestCode
    Hello
    nullHello
    public class TestCode
         public static void main(String[] s)
         {     String s1 = "";
              String s2 = null;
              System.out.println(s1 + "Hello");
              System.out.println(s2 + "Hello");
    }

    The difference is that an empty String is just empty but a null String has no value (i.e. it is not instantiated) this has signifigance since all Strings are objects.

  • Possible to rename popup strings upon changing `Chapter` field in `Composition Marker` dialog?

    Hi There,
    I am in need to dynamically change the values inside a popup upon a user changing the value of the `Chapter` field within the `Composition Marker` dialog.  I realize that we cannot add new string values to a popup at runtime, but I read a thread in this forum, and in the `Supervisor` example in the SDK, that it is possible to rename them.  However, it seems like the event for making the changes to those values is triggered by a user changing values in the parameter set of the plugin itself. 
    So my idea is to populate a popup param with 20 strings--for example, 1, 2, 3, . . . 20.  Then when a user enters in a string within the `Chapter` field in a `Composition Marker` dialog, it updates the popup list to show the user entered string.  Is this possible?  I know I can access the string in the `Chapter` field via javascript ExtendScript.  Can I do it within C++ code?
    Thanks for your time and help!

    to get the marker string you should use AEGP_GetMarkerString() with AEGP_MarkerString_CHAPTER.  as for changing the popup values, by looking at the thread you pointed out, it seems it's possible to change the popup names at any time, and not during a specific code. the entire accessing of the popup data in that example was done using AEGP calls, which should not be affected by the calling time. (except for rare cases) never tried it myself. can vouch for my advice here.  since popup param's amount of entries can't be changed dynamically (to the best of my knowledge), you can create 30 (or any other number) of hidden popup params, starting with 1 entry and ending with 30 entries in it, and make only the param that fits your purposes best at that moment - visible.

  • Array to spreadshee​t string. Empty formatter ignored. BUG

    when you want to create an array string that has no seperator you cannot use the Array To spreadsheet string function:
    This is a bug in my opinion.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

    smercurio_fc wrote:
    This has been a known issue for a LONG time. Technically, it's not a bug since the behavior of the function is correct based on its design. It uses a default value of a tab if it receives an empty string. It's no different than with VIs having a default value for a control.
    I disagree with that. Our own VIs behave like that since we don't know if anything is wired to a terminal or not. But many LV primitives work differently if you wire something or not. Index Array for 2D or higher dimension arrays for instance works differently when wiring a 0 (default value) or leaving the terminal unwired.
    So I would expect the primitive to accept an empty string.

  • Is it possible to convert from string to variant?

    Hi!
    I would like to convert a text string to variant. I'm doing this because I would like to merge a couple of signals and then save all the signals in a lvm-file. Could someone please explain how to convert from text to variant, is it possible?
    Thanks in advance!
    Regards,
    Mattias
    Attachments:
    Merge signals.JPG ‏27 KB

    What you are attempting to do is possible, but might not give you the results you expect.  All you need to do is convert your string to an array of U8s using the String to Byte Array conversion primitive.  In the file, you will get a single character per line of the file expressed as the ASCII code.  When you read it, convert to U8s, then use Byte Array to String to get your string back.
    You may also want to read up on LVM files.  There are several places to put strings that work a little better than this.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

Maybe you are looking for

  • FB65 - Vendor credit memo

    Hello Experts, I have a question reg vendor credit memo. When I post a credit memo, vendor account gets debited and what will be the GL account used for credit entry?   Am using this credit memo to balance the wrongly posted vendor invoice. Any help

  • Comments on this style of scripting.

    Hi, This is my first rman shell script, still learning the ropes. Just looking for any commentary on the pro's cons of how I'm doing this. You'll notice instead of saving a job in RMAN with "create script" I've elected to leave the script in the back

  • Can I isolate part of a shape path to simplify if?

    Hello, I want to simplify part of a complex shape.  Is it possible to isolate part of a shape path and simplify it, leaving the rest of the shape with the original number of anchor points? Thank you

  • ServletException - Failure to deploy "action" to preload on startup

    I am getting a number of exceptions when attempting to deploy my portal app on the server. For each WebApp in the Application it fails to preload the "action" servlet. The stack trace is shown below. It seems that there must be something wrong with m

  • Blanket sales Order's number missing on Sales orders releases

    Hello, i noticed that when u make a sales order based upon a blanket sales order (or just a release that is nearly the same), on the order header (or lines) there isn't any notice about the blanket sales order whom this sales order is referred to. Do