String class

Why print the String object in class displays the content of this variable and do not String@H=hashCode (). ?

wbecause, if you print an object reference, and then uses toString() to print message internally, which is originally written in object class with ' getClass () .getName () + ' @' + Integer.toHexString (hashCode ()) "logic." but in the class String ToString is overridden to print the contents of the string.

Tags: Oracle

Similar Questions

  • [ACCIDENT] Crash when using ' equal to ' function of the String class

    When I use "equal to" function of the String class to compare 2 channels, the app will crash.

    Examples: pn_infopush.equals (PN_INFO_TIMER)

    I have to use "is" instead of "equal". The application will run normarly

    Does anyone have any idea who? I don't understand why.

    Thanks for your support!

    Hello

    Is there a chance that your variable can get a null value?

    Calling .equals not a null object can cause this.

    What type of exception you get? Can you provide a stacktrace?

  • What is the method of the String class's trim() in special cases?

    You are looking for here ( String (Java Platform SE 7) ), I understand that the method of the String class's trim() 'returns a copy of the string with white spaces of early and omitted end', but I don't understand what the last special case Unicode characters is exactly.

    You are looking for here ( list of characters Unicode - Wikipedia, the free encyclopedia ), I see that U + 0020 is a space character, and I also see the characters that follow the character space (for example, the exclamation point character).

    So, I decided to write a sample of the size of the code to try to reproduce the behavior that I quoted (from the documentation of the API of the trim method) in the comment from several line of this code even example. Here is the code example. :

    public class TrimTester {
    
        public static void main(String[] args) {
           
            /*
             * "Otherwise, let k be the index of the first character in the string whose code
             * is greater than '\u0020', and let m be the index of the last character in the
             * string whose code is greater than '\u0020'. A new String object is created,
             * representing the substring of this string that begins with the character at
             * index k and ends with the character at index m-that is, the result of
             * this.substring(k, m+1)."
             */
            String str = "aa!Hello$bb";
            System.out.println(str.trim());
        }
    }
    

    However, what is printed is "aa." «Hello bb$ "(without the quotes) instead of «!» "Hello$" (without the quotes).

    Any input to help me better understand what's happening would be greatly appreciated!

    Hallo,

    I think that the characters 'a' and 'b' both have greater than '\u0020' code, so your entire string is returned by the trim () - method, then the first character of the string whose code is superior to ' \u0020 has index 0, and the last character whose code is greater than '\u0020' a index 10. All printable characters have codes greater than 0020, try "\r\ntest". After trim(), you get 'test '.

    Regarding

    Rafal Z

  • mount the java.lang.String class oracle.jbo.domain.Number class

    Dear Sir

    How to mount an oracle.jbo.domain.Number chain?

    Thank you

    Anatoliy

    Try this:

    Variable number = null;
    String var = 'var ';
    variable = new Number (Integer.ParseInt (var));

    Concerning

  • problem installing Canon solutions drive... Invalid class string

    I have been using Canon ZoomBrowser program provided with an EOS camera. Recently, I bought a Canon Powershot camera and tried to install the cd of solution because the camera was not recognized by the system. After installation it did not work and the error of invalid class string appeared.

    I uninstalled all programes cannon and tried again but still get the error message of class string not valid. Can someone help please.

    Right-click, choose Properties, Compatibility tab, and then choose run this
    Program as an administrator
     
    --
    ..
    --
    "omjohn" wrote in message news: 6f6c8517-b195-4aad-a68c-3521328b265b...
    > I've been using Canon ZoomBrowser program delivered with an EOS
    > camera. Recently I bought a Canon Powershot camera and tried to install the
    > solution cd that the camera was not recognized by the system. After
    > installation it did not work and invalid class string error appeared.
    >
    > I uninstalled all programes cannon and tried again, but still get no valid
    > Error message String class. Can someone help please.
    >
     
     
  • Features of LabView string StartsWith as in c#?

    Hi all

    in c# (.NET) there is a good class: String

    There, it is possible for example to get information, if the string startswith one substring special.

    Is that what this possibility in LabView? Y at - it these LabView vi, which offers this feature? (Excerpts)?

    So I ask you:

    I want to create a switch/case (structure-case) block in labview for this code:

    If (String.StartsWith ("XYZ")) step in case1

    another step if (string.startswith ("DEF")) in CAS2

    ...

    BTW:

    It would be great if someone could create polymorphic VI with these functions:

    (from c# string class)

    public object Clone();
    public static int Compare (string strA, string strB);
    public static int Compare (string strA, string strB, Boolean ignoreCase);
    public static int Compare (string strA, strB string, StringComparison comparisonType.greater);
    public static int Compare (string strA, string strB, Boolean ignoreCase, CultureInfo culture);
    public static int Compare (string strA, string strB, CultureInfo culture, CompareOptions options);
    public static int Compare (string strA, int indexed, string strB, indexB int, int length);
    public static int Compare (string strA, int indexed, string strB, indexB int, int length, Boolean ignoreCase);
    public static int Compare (string strA, int indexed, string strB, indexB int, int length, StringComparison comparisonType.greater);
    public static int Compare (string strA, int indexed, string strB, indexB int, int length, Boolean ignoreCase, CultureInfo culture);
    public static int Compare (string strA, int indexed, string strB, indexB int, int length, CultureInfo culture, CompareOptions options);
    public static int CompareOrdinal (string strA, string strB);
    public static int CompareOrdinal (string strA, int indexed, string strB, indexB int, int length);
    public int CompareTo (object value);
    public int CompareTo (string strB);
    Public Shared Function Concat (IEnumerable values );
    public static string Concat(IEnumerable values);
    Public Shared Function Concat (object arg0);
    public static string Concat (params object [] args);
    Public Shared Function Concat (params string [] values);
    Public Shared Function Concat (object arg0, object arg1);
    Public Shared Function Concat (string str0, string str1);
    public static string Concat (object arg0, object arg1, object arg2);
    Public Shared Function Concat (string str0, string str1, string str2);
    public static string Concat (object arg0, object arg1, arg2, object arg3);
    public static string Concat (string str0, string str1, str2, string, string str3);
    public boolean Contains (string value);
    Public Shared Function Copy (string str);
    public final void CopyTo (int sourceIndex, destination of char [], int destinationIndex, int count);
    public boolean EndsWith (string value);
    public boolean EndsWith (value string, StringComparison comparisonType.greater);
    public boolean EndsWith (string value, Boolean ignoreCase, CultureInfo culture);
    public boolean Equals (object obj);
    public boolean Equals (string value);
    public static Boolean Equals (String, b string);
    public boolean Equals (string, StringComparison comparisonType.greater value);
    public static Boolean Equals (string a, b string, StringComparison comparisonType.greater);
    Public Shared Function Format (string format, object arg0);
    Public Shared Function Format (string format, params object [] args);
    Public Shared Function Format (IFormatProvider provider, format of the string, params object [] args);
    Public Shared Function Format (string format, object arg0, object arg1);
    Public Shared Function Format (string format, object arg0, object arg1, object arg2);
    public CharEnumerator GetEnumerator;
    public override int GetHashCode();
    public TypeCode GetTypeCode();
    public int IndexOf (char value);
    public int IndexOf (string value);
    public int IndexOf (char value, int startIndex);
    public int IndexOf (string value, int startIndex);
    public int IndexOf (string value, StringComparison comparisonType.greater);
    public int IndexOf (value char, int startIndex, int count);
    public int IndexOf (string value, int startIndex, int count);
    public int IndexOf (string value, int startIndex, StringComparison comparisonType.greater);
    public int IndexOf (string value, int startIndex, int count, StringComparison comparisonType.greater);
    public int IndexOfAny (char [] anyOf);
    public int IndexOfAny (char [], int startIndex anyOf);

    public int IndexOfAny (anyOf char [], int startIndex, int count);
    public string Insert (int startIndex, string value);
    Public Shared Function Intern (string str);
    public static IsInterned (string str);
    public boolean IsNormalized();
    public bool IsNormalized (NormalizationForm normalizationForm);
    public static Boolean IsNullOrEmpty (string value);
    public static Boolean IsNullOrWhiteSpace (string value);
    Public Shared Function Join (separator string, IEnumerable values);
    Public Shared Function Join(separator string, IEnumerable values);
    Public Shared Function Join (separator string, params object [] values);
    Public Shared Function Join (separator string, params string [] value);
    Public Shared Function Join (separator string, string [], int startIndex, int count);
    public int LastIndexOf (char value);
    public int LastIndexOf (string value);
    public int LastIndexOf (char, int startIndex value);
    public int LastIndexOf (string value, int startIndex);
    public int LastIndexOf (string value, StringComparison comparisonType.greater);
    public int LastIndexOf (value char, int startIndex, int count);
    public int LastIndexOf (string value, int startIndex, int count);
    public int LastIndexOf (string value, int startIndex, StringComparison comparisonType.greater);
    public int LastIndexOf (string value, int startIndex, int count, StringComparison comparisonType.greater);
    public int LastIndexOfAny (char [] anyOf);
    public int LastIndexOfAny (char [], int startIndex anyOf);
    public int LastIndexOfAny (anyOf char [], int startIndex, int count);
    public string Normalize();
    public string Normalize (NormalizationForm normalizationForm);
    public string PadLeft (int totalWidth);
    public string PadLeft (totalWidth int, char paddingChar);
    public string PadRight (int totalWidth);
    public string PadRight (totalWidth int, char paddingChar);
    public string Remove (int startIndex);
    public string Remove (int startIndex, int count);
    public string Replace (char oldChar, char newChar);
    public string Replace (string oldValue, string newValue);
    public string [] Split (params char [] separator);
    public string [] Split (separator char [], int count);
    public string [] Split (char [], StringSplitOptions options separator);
    public string [] Split (String [], StringSplitOptions options separator);
    public string [] Split (char [], int count, StringSplitOptions options separator);
    public string [] Split (String [], int count, StringSplitOptions options separator);
    public boolean StartsWith (string value);
    public boolean StartsWith (value string, StringComparison comparisonType.greater);
    public boolean StartsWith (string value, Boolean ignoreCase, CultureInfo culture);
    public string Substring (int startIndex);
    public string Substring (int startIndex, int length);
    public char [] ToCharArray();
    public char [] ToCharArray (int startIndex, int length);
    public string ToLower();
    public string ToLower (CultureInfo culture);
    public string ToUpperInvariant();
    Public Overrides Function ToString();
    public string ToString (IFormatProvider provider);
    public string ToUpper();
    public string ToUpper (CultureInfo culture);
    public string ToUpperInvariant();
    public string Trim();
    public string Trim (params char [] trimChars);
    public string TrimEnd (params char [] trimChars);
    public string TrimStart (params char [] trimChars);

    So I ask you:

    I want to create a switch/case (structure-case) block in labview for this code:

    This can be done already with the structure of the case, you can make simple analysis in the case selector, which takes a string as input.

    Type in the case of the first case "XYZ".... "XYZ".

    Enter the next case "DEF".... "DEF ~".

    Next is the empty string, the default value.

    How does this work:

    The "XYZ...". "XYZ ~ ' matches all strings that begin with XYZ and any ascii value after the ~ is the highest value printable 7-bit ascii for that catches all the other characters.

    Option 2 is parse (there is expression reg very good vi in the channel palette) the string and create if a corresponding to the value of the integer can habdle unique integers in the structure of the case.

    There are so many ways to do it without a wrapper for the string .net class, I have provided some quick methods

  • How to get page amx text and open it in a class file in oracle MAF 12.1.3

    I created a simple form using amx as below:

    <? XML version = "1.0" encoding = "UTF-8"? >

    " < amx:view xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance "

    ' xmlns:amx = ' http://xmlns.Oracle.com/ADF/MF/AMX "xmlns:dvtm =" http://xmlns.Oracle.com/ADF/MF/AMX/DVT ">

    < amx:panelPage id = "pp1" >

    < amx:facet name = "header" >

    < amx:outputText value = "Header" id = "ot1" / >

    < / amx:facet >

    < amx:facet = "primary" name >

    < amx:commandButton id = "cb1" / >

    < / amx:facet >

    < amx:facet = "secondary" name >

    < amx:commandButton id = "cb2" / >

    < / amx:facet >

    < amx:panelFormLayout id = "p1" >

    < amx:inputText id = "i2" hintText = 'enter something '.

    Label = "Edit Text" > < / amx:inputText >

    < amx:inputText id = "text1" label = "" enter password: ""

    secret = "true" / >

    < / amx:panelFormLayout >

    < amx:commandButton id = "c1" text = "Send" action = "getFormDetails" > < / amx:commandButton >

    < / amx:panelPage >

    < / amx:view >

    I want to extract text entries and access in a class file. Please help me.

    You can store values in pageflowscope and then get these in javaclass.

    Example:

    «"" "AMX page:»»"»

    secret = "true" / >

    Java class:

    public void getFormDetails() {}

    AdfELContext adfELContext = AdfmfJavaUtilities.getAdfELContext ();

    ValueExpression ve = AdfmfJavaUtilities.getValueExpression ("#{pageFlowScope.name}", String.class);

    String val = (String) ve.getValue (adfELContext);

    }

  • A group of Radio with a class CSS formatting

    With the help of APEX 4.2.3.00.08

    I created this css class called rb1 in my section of the HTML header.

    < style type = "text/css" >

    RB1 {- webkit - appearance: none;}

    background-color: #C9EFF3;

    border: 1px solid #cacece;

    box-shadow: 0 1px 2px rgba (0,0,0,0.05), insert 0px-10px 15px-rgba (0,0,0,0.05) 12px;

    padding: 3px;

    border-radius: 3px;

    display: inline-block;

    ' position: relative '.

    }

    < / style >

    I put < rb1 > and < / rb1 > tags around one of my headers element and sure enough, it works fine.

    Now, I would use rb1 as setting style in shape for the members of a group of radio buttons.

    I don't know (or at least I think I know) of this blog http://vincentdeelen.blogspot.com/2013/11/pimp-my-site.html that "these classes can be added to the attributes page field items, in the attribute"Class CSS of HTML Form element", under the heading 'Elément'."  But my question is: exactly what is happening in this field element form HTML CSS Classes ?  I tried just a plain rb1, < rb1 >, class = "rb1" and so on.  There seems to be a lack of useful documentation - I can't find a doc that tells exactly what to put in this field or in what format.  For example, a search of the documentation Oracle APEX site can't find any occurrences of the string "Classes CSS élément HTML Form" at all.

    Anyway, no matter what I tried, in this area, and in the two fields below, the formatting of radio button does not change.

    However, I can directly this code in the element form attributes Option:

    style = "- webkit - appearance: none;" background-color: #C9EFF3; border: 1px solid #cacece;      box-shadow: 0 1px 2px rgba (0,0,0,0.05), insert 0px-10px 15px-rgba (0,0,0,0.05) 12px;      padding: 3px;      border-radius: 3px; »

    And indeed is implementing in the shape I want.  But unfortunately, this field has a length limited, and it kind of defeats, the goal of creating a reusable CSS class, isn't?

    What escapes me, please?

    Hello

    I think it's the best place CSS inline, in the title of the page CSS.

    Anyway your style selector is false. For the class, it should be like this

    .rb1 {
     -webkit-appearance: none;
     background-color: #C9EFF3;
     border: 1px solid #cacece;
     box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05);
     padding: 3px;
     border-radius: 3px;
     display: inline-block;
     position: relative;
    }
    

    Point of note before rb1. This means that it is class

    Then you place just rb1 to Classes CSS to HTML form elements

    Kind regards

    Jari

  • Treatment/string of ASCII characters and performance - char [] or String?

    Hello everyone

    I am a novice on Java, I have training C programming procedure.

    I read many very large (several GB) comma/quote separated ASCII CSV text files and run various types of prior treatment on them, before loading into the database.

    I am using Java7 (more later) and using NIO.2.

    IO performance are very good.

    My question concerning the performance of the use of tank tables [i] compared to the string and StringBuilder classes using methods charAt().
    Read a file, a record of line at a time and then I deal with. The regular expression is not an option (too slow and can not handle all cases, I need to cover).

    I noticed that access a single character of a given string (StringBuilder or too) class using methods String.charAt (i) is several times (5 times +?) slower than referring to a tank an array with indexes.

    My question: is this correct observation re charAt() against tank [i] difference in performance or I do something wrong in the case of a String class?

    What is the best (performance) way to treat strings in Java, if I need to treat a character at a time?

    Is there another approach that I should consider?

    Thanks in advance

    You're going to have to show us how you schedule, because I've come up with just a quick test below and I get the following results:

    public class Scratch {
         public static void main(String args[]) {
              char minChar = 32;
              char maxChar = 126;
              char[] chars = new char[1000];
              char currentChar = minChar;
              for (int i = 0; i < 1000; i++) {
                   chars[i] = currentChar;
                   currentChar++;
                   if (currentChar > maxChar) {
                        currentChar = minChar;
                   }
              }
              String myString = String.copyValueOf(chars);
              Date startDate = new Date();
              timeString(myString);
              Date endDate = new Date();
              long stringTime = endDate.getTime() - startDate.getTime();
              startDate = new Date();
              timeChars(chars);
              endDate = new Date();
              long charTime = endDate.getTime() - startDate.getTime();
              System.out.println("stringTime = " + stringTime);
              System.out.println("charTime   = " + charTime);
         }
    
         private static void timeChars(char[] chars) {
              int length = chars.length;
              for (long i = 0; i < 10000000; i++) {
                   for (int j = 0; j < length; j++) {
                        char c = chars[j];
                   }
              }
         }
    
         private static void timeString(String myString) {
              int length = myString.length();
              for (long i = 0; i < 10000000; i++) {
                   for (int j = 0; j < length; j++) {
                        char c = myString.charAt(j);
                   }
              }
         }
    }
    

    stringTime = 42
    charTime = 30
    This makes some sense as charAt() go check it out.

  • How to split strings?

    Hello

    I'm using action made by Christophe (http://www.vcoteam.info/learn-vco/code-snippets-cancel-one-of-your-running-workflows.html) in order to cancel some workflows.

    Since the selection for tokens window does not display the parameters of the token, I created another entry for my workflow that is supposed to contain the name of the virtual machine, only for infomational purposes.

    I created an action to do this. When I use just "return myWorkflowToken.getInputParameters ();" then all settings are written to the input box.

    In my case, it looks like this:

    {ram = 3000.0, date = Mon Jan 24 16:25:16 THIS 2011, vm = < @id = FinderResult' VC:VirtualMachine/si0vm271/vm - 852' @name = "si0vm562" >, UC = 3.0}

    Since I need only the name of the virtual machine, in this case the part after @name (si0vm562), I need to retrieve it somehow off the chain.

    In the Orchestrator API, I found the String class with the method 'split '.

    At first, I tried to split the string into two parts using this code:

    var params_s = myWorkflowToken.getInputParameters ();
    var params_a_s = params_s.split ("name");
    return params_a_s [1];

    But when I run the workflow, the input dialogue tells me that the "split" function cannot be found.

    How can I retrieve the VM name on the report of a running workflow?

    Thank you

    Concerning

    Andreas

    Hi Andreas,

    I don't think that splitting strings works for your case.

    In fact workflowToken.getInputParameters () does not return a string. It is ch.dunes.scripting.jsmodel.JSProperties instead (you can check this of the Orchestrator client tools-> API Explorer). The split function is not found on the params_s variable.

    In order to achieve your goal, you can try the following:

    get the vm parameter

    Use the parameter name. This is the vm used according to the result of your message

    VM var = workflowToken.getInputParameters () .get ("vm");

    You can check for safety if the virtual machine is defined, except that the virtual machine is the required parameter

    If (vm! = null) {}

    return vm.name

    }

    The code snippet above you should return the value set for the parameter of the virtual machine.

    Hope this helps,

    Martin Marinov

  • Count the number of times a letter appears in a string and the number of real-time display?

    Hello

    I need to count how many times a letter is contained inside a string that the user types in the text box (i.e., real-time) and display the counter on the page? I would really appreciate if someone can give me some advice how to do this in ActionScript 3.0/Flash CS6.

    Thank you very much in advance!

    A single element, you should not use is a listener for the CHANGE event of a textfield.  You will use as a trigger to check the text in the TextField.

    The details of how you check the text may depend in part on how the text is allowed to enter, but you essentially have to examine each character is entered and determine if it is the character you intend and if so, add it to t a sum.  You can use the String class charAt() method to get individual characters.

  • table, equivalent string.replace

    Hello

    What can I use as a method to replace on a table?

    Replace the method of the done String class a number of things.  First, it locates a match of what is supposed to be replaced and secondly it replaced by something else.  For a table, you will need to take into account these two steps.  The first step could be carried out using the indexOf() method.  The appearance of replacement could be as simple as the reallocation of the element which is found at index... table [i] = something again.

    So if you wanted to combine them into a single line of code, that would be something to the effect of...

    Array [Array.IndexOf (Old)] = new;

    Example:

    var array: Array = new Array (2,3,4,5).

    Array [Array.IndexOf (4)] = 8;

    trace (Array);  traces 2,3,8,5

  • "new static class qualified."

    Hi all

    I have a class of RandomGenerator with a nested public static String class, which extends from CountingGenerator with a nested class public static String, which in turn has a next() method to generate a following string object. Now, how do I actually use, how do I get a reference to the nested class so that I can call the following method. I tried this code, but it throws RuntimeException: code source Uncompilable - qualified new static class:
    public class FillTreeSet {
        public static void main(String[] args) {
            RandomGenerator rg = new RandomGenerator();
            RandomGenerator.String rgs = rg.new String();   //throws the exception
        }    
    }
    It's the RandomGenerator class:
    public class RandomGenerator {
        public static class String extends CountingGenerator.String {
            { cg = new Character(); }
            public String() {}
            public String(int length) { super(length); }
        }
    }
    And it comes to the CountingGenerator class:
    public class CountingGenerator {
        public static class String implements Generator<java.lang.String> {
            private int length = 7;
            Generator<java.lang.Character> cg = new Character();
            public String() {}
            public String(int length) { this.length = length; }
            @Override
            public java.lang.String next() {
                char[] buf = new char[length];
                for (int i = 0; i < length; i++)
                    buf[i] = cg.next();
                return new java.lang.String(buf);
            }
        }
    }
    Thanks in advance.
    PR.

    Since this is a static inner class, you must specify:

    new RandomGenerator.String();
    

    Your code would work if it were a non-static inner class.

  • String.replaceAll () takes an argument of regex?

    For the experienced:


    It is not not to solve a problem to find work on hand made, but something for the discussion of other possibilities.

    I have a file which must cut them before use. The file has several lines, and for each line of the format is ('X' is used to mark the beginning and the end of the line to show the invisible white space):
    X12345678   9876543210 X
    I need to replace the three spaces between two numeric characters with one and eliminate space of tailings. My code:
    String line = null;
    while ((line = inputStream.readLine()) != null) {
        Pattern pattern = Pattern.compile("\\s+");
        Matcher matcher = pattern.matcher(line);
        line = matcher.replaceAll(" ").trim();
        System.out.println("(" + line + ")");
    Which works very well and produces the desired result:
    (12345678 9876543210)
    Would but not be simpler if replacement of the String class methods would do the same job? It is, say,
    String line = null;
    while ((line = inputStream.readLine()) != null) {
        line.replaceAll("\\d+", " ").trim();
        System.out.println("(" + line + ")");
    I do this using JDeveloper 11.1.1.3, located in C:\Oracle\Middleware\jdeveloper\jdeveloper.exe and found out, C:\Oracle\Middleware\jdk160_18\jre\bin\client\jvm.dll is probably the JDK using the JDeveloper. I checked the API document online for Java version 6 to http://download.oracle.com/javase/6/docs/api/index.html, and it shows that the String class has these replacement methods that take the regex:
    String replaceAll(String regex, String replacement) 
    String replaceFirst(String regex, String replacement) 
    But when coding, typing < font color = "green" > replace < / police > as a result of the variable string < font color = "green" > line < / police >, all the insight of Code appears include:
    replace(Char, Char)                  String
    replace(CharSequqnce, CharSequence)  String
    replaceAll(String, String)           String
    replaceFirst(String, String)         String
    This seems to say that regex is not supported. If I do not take into account the suggestion of the foresight of Code and try anyway:
    line.repaceAll("\\d+", " ");
    
    or
    
    line.replaceAll("  *", " ");
       // This second attempt uses the familiar regular expression in unix,
       // such as would be used in
       // $ echo $line | sed 's/  */ /g'
    JDeveloper complain about this attempt. But it does not work either, simply echo back which entered into him.

    What I want to do is play with it to find a way of writing acceptable regular expressions in the JDK in JDeveloper. What the API documentation has said is that regex is accepted and taken in charge, but his behavior, we know not if this is the case with the JDeveloper, or if it is supported, but the suggestion of the insight of Code isn't fair and my regular expressions are not correct.

    All suggestions and insight would be much appreciated.


    Newman

    System.out.println ("1 2 3 4".replaceAll ("\\s {2},", "X")); is back "X 1 2 X 3 X 4"(p. ex. espaces consécutifs seulement sont obtenant remplacés). "»
    I have not tested, but the \s character class may not include new lines. You can use \n If you want to include line breaks as well. Also, I used JDeveloper and jdk, I used is one that comes with Jdeveloper(e.g. \Oracle\Middleware\jdk160_21).

    Edited by: Hyangelo may 9, 2011 11:03

    Edited by: Hyangelo may 9, 2011 11:05

  • String Concat does not work

    Hi all!

    I have the following code:
                    if (roundedWorstCompressFactor < 0.75 || roundedAvgCompressFactor < 0.75 || roundedBestCompressFactor < 0.75) {
                        String impossibleCFs = "";
                        if (roundedWorstCompressFactor < 0.75) impossibleCFs.concat("Worst Case");
                        if (roundedAvgCompressFactor < 0.75) impossibleCFs.concat(" Average Case");
                        if (roundedBestCompressFactor < 0.75) impossibleCFs.concat(" Worst Case");
    
                        jLabel23.setText("It isn't possible to achieve " +  impossibleCFs + " CFs");
                    }
    When I debugged my code, I realized that even inside if statements evaluates to true, the concat method makes no difference. Text of a jLabel resulting becomes so "is not possible to obtain the CFs. Why the String class concat method does not work?

    When you apply the function concat on string, it does not alter the original string, it returns a new string with the desired result. Therefore, assing the value returned to your variable. So, try this:

       impossibleCFs = impossibleCFs.concat("Worst Case");
    

    As an alternative, also review the StringBuffer data type. It has the function append() you can use without affecting the result to the original variable. Once you're done, you can use StringBuffer.toString () to get the final string.

Maybe you are looking for