String 5 « string « Java Data Type Q&A





I need to get the number for Trigger Count. ...

1. How to get Correct string( about charset )    coderanch.com

TOMCAT3.2.1 + Oracle 8i + JDK1.2.2 My program get some records from database , and want to show it in browser correctly . Interesting thing is : in DB , some fields has value like "0015","0036" ,but after i read its value from database ands print it to TOMCAT'slog , it beccomes "0x30303135" "0x30303336", see , it seems something like ASCII ...

2. Strange string    coderanch.com

Linux + TOMCAT3.2.1 + ORACLE8.1.7 I have a field named TITLECODE , i defined it as VARCHAR2 . And then insert some tuples into DB. their TITLECODE Field is like '00123456' . When i use JDBC API to access TITLECODE field , what i get is like "0x3030313233343536". As all you can see , it give me its ASCII code i ...

3. query strings    coderanch.com

6. Query String in Request Dispatcher    coderanch.com

8. about unite string    coderanch.com

9. A Question in Context.log(String Mes)    coderanch.com





10. Lots of Query Strings: Best Approach    coderanch.com

gregg, whether You use struts or not, you may be better of using some sort of MVC. Struts is just an implementation of the good old and well appreciated MVC pattern. Anyway, the struts classes help you a bit, now you have to write it yourself. What I mean is the following. Your code of what the user wants is in ...

11. String    coderanch.com

I think what you can do to get the filename out of filepath is, treat filepath as string and get the index of last occurence of "/" in the filepath and substring the filename from that index value till the end of the filepath. For example: String filepath = "c:/documents and setting/desktop/cdss/file1.txt" Here in this case filename is file1.txt. To get ...

12. Getting Query String Params From A Post    coderanch.com

Is it not possible to get params from the query string using a doPost? I have the following URL: https://www.findworks.com/findworks/servlet/SaleUploadSelection.do?HiddenSampleSessionId=123456789abcdef&auctionID=489&systemFolder=test&date=2005-10-01&contactID=413 I am not able to get any of the parameters in my servlet. I don't know why. Here is the doPost: protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String picDir = ApplicationInfo.getInstance().getDevelopmentDirectory(); String systemFolder = ...

13. request.getParameterMap() - getting the Strings - a better way?    coderanch.com

Hi folks - attempting to simplify here pls. exuse if not clear, let me know - I want to pass a Map of all the request parameters from my Servlet code into a method in another object, so they can be moshed and inserted into DB. So I have come up with something like this in the servlet processor: public class ...

14. Showing string in different language    coderanch.com

15. request string % problem    coderanch.com

16. Query Regarding String ???    coderanch.com

Hi, I have one input String(one complete line)and I have one pattern(that pattern includes 5 words), now i want to check in input string with my pattern that how many times that pattern exists in input string. Can any one please guide me how i can do that. Thanks & Regards Bikash





17. Abt String Class    coderanch.com

Hai Guys, i have a doubt reg String class.We all know that String's r constant and r immutable. Just observe this line: String s="Hello"; s=s+" World"; here contents of s is changed.i am not getting that what is it mean by immutable. Would u any one plz explain me the topic clearly. also... what is hashcode, and what & how is ...

18. String    coderanch.com

19. Strings and StringBuffers    coderanch.com

From the StringBuffer API: String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved. So StringBuffer methods are synchronized internally. ...

20. Compressing and Decompressing strings in Java    coderanch.com

Hi Chitra, I just tried the following code and it works...... import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPInputStream; import java.io.*; class StringEg { public static void main(String[] args) throws IOException { String str = "Test String"; FileOutputStream fos = new FileOutputStream("str.txt"); GZIPOutputStream gzos = new GZIPOutputStream(fos); gzos.write(str.getBytes()); gzos.close(); FileInputStream fis = new FileInputStream("str.txt"); GZIPInputStream gzis = new GZIPInputStream(fis); //I am taken the size of ...

21. String to numeric and back    coderanch.com

This should be easy - but I'm having trouble working through it. here's the situation. I have a field which MUST be 7 characters in length, is numeric in nature, and needs to have arithmetic functions applied. So, I guess I have multiple questions: 1) is there any way to "fix" the length of a numeric data type buy padding with ...

22. Strings    coderanch.com

23. Different behaviour with string objects    coderanch.com

Hi, The string objects behaving differently in differnt situations. Plase find the following code giving differnt result. if("String".replace('t','t') == "String") System.out.println("Equal"); else System.out.println("Not Equal"); /*************************************/ if("String".replace('g','G') == "String".replace('g','G')) System.out.println("Equal"); else System.out.println("Not Equal"); /*************************************/ if(" String ".trim() == "String") System.out.println("Equal"); else System.out.println("Not Equal"); Please let me know why I am getting different results in the above three sinarios. Thanks & Regards Rajesh ...

24. Playing with String    coderanch.com

If you don't want to mess with a StringBuffer, you can use the indexOf() and substring() methods of String. Like this: String a = "900(10001)"; String b = a.substring(a.indexOf("(")+1,a.indexOf(")")); substring(int,int) takes the first and last index of the string and creates a new substring of it. So if you find the indexOf() the "(" and ")" and pass those ints to ...

25. Object or String Problem. Need Help!    coderanch.com

Can anybody tell me what is wrong into this code. ERROR: Incompatible Type Found : java.lang.Object Required: java.lang.String error occur at (iRow //////////////// private void insertLedgerBalance(int iRow) { try{ if (optReceipts.isSelected()) { String atCode = tbl_PettyReceipt.getValueAt(iRow, 0); String atAmount = tbl_PettyReceipt.getValueAt(iRow, 3); } else if(optDeduction.isSelected()) { for (int a = 0; a < tbl_PettyReceipt.getRowCount(); a++) { String atCode = tbl_PettyReceipt.getValueAt(iRow, 0); ...

26. String Operation    coderanch.com

Hi Lucky, Couldn't understand why the second method work. It doesn't make sense. If the vector is empty and elementAt(0) is called, java.lang.ArrayIndexOutOfBoundsException is thrown. If the vector is not empty and the elementAt(0) is called successfully, an object will be returned. A NullPointerException is thrown when trying to access members of a null object. I wrote a simple code to ...

27. Big Java Strings    coderanch.com

Hi Randy, The String class ought to work with up to 2x10^31 characters, or about 4GB of data (each character is two bytes.) Most JVMs can't have a Java heap even half that size, so the practical limit is about 1800MB. How are you running into this limit? Maybe your application design could be changed?

28. string management    coderanch.com

hi friends, i have a problem on managing input strings on a program. i have to make a program in which on hitting "enter" or a particular word the program should show some output. the code of my program: - -------------------------------------------------------- import java.lang.*; import java.util.*; import java.io.*; public class test { public static void main(String args[]) { try { //ctrl-c to ...

29. string management    coderanch.com

hi friends, i have a problem on managing input strings on a program. i have to make a program in which on hitting "enter" or a particular word the program should show some output. the code of my program: - -------------------------------------------------------- import java.lang.*; import java.util.*; import java.io.*; public class test { public static void main(String args[]) { try { //ctrl-c to ...

30. element substitution into a string    coderanch.com

I'm looking for approaches and solutions to element substitution into a string. For example a string with elements to be will look like. Dear ${first_name} ${last_name}, Welcome to our Game Club. We will contact you via you email ${email}. Where I need to substitute values for the elements that are formated as ${element_name}. So in the example above the elements to ...

31. class method and strings    coderanch.com

You might as well bookmark the link to the Java API: Java API If you look under String, you will find a method that I think you will see could be very helpful to you called toCharArray() The java API is your friend. When I need to to something that I don't know how to do in java, I usually go ...

32. String question    coderanch.com

33. About String    coderanch.com

The String class represents character strings. All string literals in Java programs, such as "prasad", are implemented as instances of this class. Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example: String str = "prasad"; This creats a string literal, sets it's ...

34. Strings, Immutablilty, and Garbage Collection    coderanch.com

Hi I'm working with code that changes the color of alternating table rows on a JSP. The following code is in a loop: String colorString = "" if (count%2 == 0) { colorString = SomeClass.A_STATIC_CONSTANT_1; } else { colorString = SomeClass.A_STATIC_CONSTANT_2; } Even though colorString is pointing to a constant, is this not creating a new string for garbage collection in ...

35. String Problem    coderanch.com

Hi, I am using getParameter() to grab a hidden field on a jsp. My problem is that the string coming back is separated by commas including an extra one on the end (ex. value1,value2,value3,) this is playing havoc with my substring. It seems to think there is another value after the last comma and is bringing me back a blank. So ...

36. Simple STRING Question!    coderanch.com

37. String[]    coderanch.com

Collection.toArray() returns Object[], even if all the elements of the Collection happen to be castable to a narrower type. Collection.toArray(Object[]) is declared to return Object[], but the run-time type of the returned array is the same as the run-time type of the array given as an argument. In your case, if you construct an array of type String[] and pass that ...

38. string diff    coderanch.com

Hi all, I want to do diff on strings. The problem is all diff programs takes files as arguments so I end up creating a temporary file and then doing diff on that. I wanted to avoid creation of temporary files as I/O might slow my application due to large number of diff requests I have to make. Is there any ...

39. String substitution and apostrophes    coderanch.com

Hi all, My first question is whether anyone can describe the proper name for what I'm doing below... is it "string replacement?" "string substituion"? Okay, so the meat of my issue is that I have messages that I am sending out to the user, and I am using MessageFormat to substitue in some string values. For example, I have a String ...

40. Combing String []    coderanch.com

String[] wordSyns = getSynonymsWord(s); String[] sentenceSyns = getSynonymsSentence(s); I would like to combine these 2 arrays into one array. Using a loop I can put it in this: String[] returnSyns = new String[wordSyns.length + sentenceSyns.length]; But that is a little messy. Can anyone suggest a more clever way (clever as is less code to write)? There has to be a class ...

41. string stemming    coderanch.com

hi everyone, i have a program that searches a file for a string. i need to be able to implement functionality to this progam so that it can find alike strings. for example when i search for run, i want runner and running to also be displayed as well as run, i have thought about just storing an array of possible ...

42. managing big data in string    coderanch.com

how to manage big string data. if i use the String object i run out of memory. Through the program i'm trying to search for a given word in a given file. The logic i've used is read the file as InputStream and covert the bytes read to String. In this string do and indexOf() of the word i'm searching. This ...

43. == in strings    coderanch.com

class strtest1 { public static void main(String args[]) { String s=new String("raja"); if(s=="raja") { System.out.println("1 is true"); } if("raja"=="raja") { System.out.println("2 is true"); } } } when u run the above code, result obtained is "2 is true". when u create the string using String s="raja", the result is "1 is true" " 2 is true" please explain how. i have ...

44. How to get rid of java.lang.String refs in JavaDoc    coderanch.com

Hi. I am running javadoc and trying to make it look a little closer to the Sun APIs where methods that return java.lang.String to not appear as "java.lang.String", but as "String". I am pretty sure this is a classpath issue, but I just can't seem to figure out how to do it.

45. String operations    coderanch.com

Hi all, The following code snippet i got it from the site: clickhere public class StringTest2 { public static void main(String[] args) { // create String references like s1,s2,s3...so on.. String variables[] = new String[50000]; for(int i = 0; i < variables.length; i++) { variables[i] = "s" + i; } // create String literals long startTime0 = System.currentTimeMillis(); for(int i = ...

46. String Doubt    coderanch.com

Originally posted by Nischal Tanna: there will be no such concept of Pass By Reference I hate to give anyone bad news, but it's true: Java has no concept of pass-by-reference. Everything is pass-by-value -- even when you're passing a reference. The name reference has a value which you can think of conceptually as the address of the "Test2" ...

47. Java Strings    coderanch.com

Hi, I think by using String t = new String("Test") it does the following: "the newly created string is a copy of the argument string" So therefore you can't compare the follwing by using the == operator: String t1 = new String("Test"); String t2 = new String("Test"); They are pointing to two different Objects so therefore you need to use the ...

48. Strings    coderanch.com

Both string literals and string objects are stored in heap memory. The references to these strings are stored in stack memory. This is done by the JVM to avoid duplicate string objects in heap memory. The difference between str="aaa" and str=new String("aaa") is about performance. str=new String("aaa") is slower because the 'new' keyword creates a new object. [ May 31, 2005: ...

49. Use of String Tokeniser to get data after second occurrence of "_"    coderanch.com

Hello , Could someone point me to how I could get data that exists after the second occurrence of the delimiter "_". Here is what I have : import java.util.StringTokenizer; public class Ex2 { public static void main(String[] args) { String sample = "lmn_a_b"; System.out.println("val = " + returnTokenizedVal(sample,2,"_")); } private static String returnTokenizedVal(String src,int indexedToken,String token){ StringTokenizer strTok = new ...

50. add to a string    coderanch.com

51. need a better way to get months out of a string    coderanch.com

Hi, I need to extact Months names out of a given string, I can do it easily using regular expressions something like: Pattern.compile(january|february|.....).matcher("22January") so that I can get the month's name found in this string but I need more professional code for doing so, I mean these months must be defined in the Date class but i dont know how to ...

52. evaluating java codes in a string, is it possible?    coderanch.com

Hi, I am wondering that can I execute codes in a varible... I mean that if I get some string from a jtextarea and this string was something meaningful for java, ( Ex: System.out.println("erdem") can java evaluate this String (Without my if statements) ? I heard about Runtime class and find a solution of creating a java source file and putting ...

53. spliting string    coderanch.com

Try: String resultString = myString.replaceAll("[\\s|\\W]*", ","); (Note the escaping of the \ i.e. \\) This returns a String that has all sequences of whitespace (\s) or (|) non-word characters (\W - basically everything except a-zA-Z_0-9) replaced with "," Now we can split it up: String[] splitup = resultString.split(","); We also could do it like: String[] splitup = myString.replaceAll("[\\s|\\W]*", ",").split(","); [ August ...

54. How to execute the mathematical string equation?    coderanch.com

I made a simple math parser in COBOL. I required spaces between terms and left out any "order of precedence" logic to keep it simple so it processes from left to right and uses recursion when it finds parens. The syntax boils down to expecting: var = term [ operator term ... ] x = 1 y = 1 + 2 ...

55. Locating Block of String - Brain Hurts    coderanch.com

I am having a hard time with this and just need a shove in the right direction. I am needing to scrape a web page here at work and locate a specific value. The page is all HTML. There is a TD element that looks like:

Trigger Count = 0

56. Object Vs String    coderanch.com

class Example { public void myMethod(Object o) { System.out.println("Object"); } public void myMethod(String o) { System.out.println("String"); } } Class Test { public static void main (String arg[]) { Example eg = new Example(); eg.myMethod(null); } } Hi Friends, Consider the above program.The output of that program is String why not Object.If I add one more myMethod(StringBuffer sb) and StringBuffer as the ...

57. getting or building strings    coderanch.com

58. strings    coderanch.com

In the example you posted, both == & .equals() may eval to true, but only due to an optimization that the Java compiler makes with String literals. As Jim pointed out, .equals() is the safer choice and should be your default when comparing strings. Only use == when you really want to check that the String references point to the same ...

59. Detect String changes    coderanch.com

Although java.awt.event.KeyListener and javax.swing.event.DocumentListener would do the trick, these catch any change - if you keep typing you get multiple events, and therefore multiple database updates. Quite costly. In this case, a combination of one of above and java.awt.FocusListener would be better - when the text is changed you set some flag, and then when you get a focusLost event, you ...

60. Doubt about creating a instance for String class    coderanch.com

You seem to be under the impression that the test variable actually "holds" the string value. It doesn't. It merely references the actual String instance. What is changed is the String object that test refers to, not the Strings themselves. The first assignment makes test refer to the String "Test", the second changes test to refer to the String "Testing again". ...

61. String    coderanch.com

62. Validatons using Strings    coderanch.com

Hi All, Can anybody please help me out. I have a text field i need to validate that text field with the following condtions using strings. 1. It should accept year (eg : 2006) 2. It should accept month (eg : 09/2006) 3. It should accept date (eg : 11/09/2006) 4. It should accept range (eg: 2006-2009) 5. Months (eg: 15 ...

63. String and Object class    coderanch.com

public class AQuestion { public void method(Object o) { System.out.println("Object Verion"); } public void method(String s) { System.out.println("String Version"); } public static void main(String args[]) { AQuestion question = new AQuestion(); question.method(null); } } Answers 1. The code does not compile. 2. The code compiles cleanly and shows "Object Version". 3. The code compiles cleanly and shows "String Version" 4. The ...

64. FileWriter.write(String str)    coderanch.com

Because you are dealing with separate processes, the solution is probably outside the realm of Java. The standard solution, as well as a best practice, is to write to a temporary file and then have the writer *rename* the file to its proper directory. Not only does this solve your problem, it keeps your target directory free from junk files caused ...

65. GC'ing String Constrants    coderanch.com

No, Alec, you've read that incorrectly. There's no relationship between an object being immutable and garbage collection. Trust me: those 100 Strings (they're not String "constants", just Strings) will be garbage collected as the need arises. Don't believe me? Change the 100 to Integer.MAX_VALUE, so that the program will create 2 billion-odd Strings, then sit back and wait for the OutOfMemoryError. ...

66. Java String Question    coderanch.com

I was just looking at the source code of java.lang.String in JDK 1.5 version and I noticed that the character array in which the actual string gets created is a 'final' variable. However, this 'final' variable is NOT initialized.(so are other private final members of the String class) How will the compiler compile this code without throwing an error? (Until JDK ...

67. Object or String?    coderanch.com

Hey Guys i tried compiling the following class n it gives "string version" as the output So my question is why does it choose to give " string version" instead of "object version" when both the methods can equally accept the null value given in the argument? ...... Any one? public class Aclass { public void amethod(Object o){ System.out.println("object version"); } ...

68. String object garbage Collection    coderanch.com

69. On String    coderanch.com

Originally posted by Mishra Anshu: In fact read this article It is good ! Actually, I would say it's pretty bloody awful. The example seems hinges on whether assignment to an object reference changes the object or not -- but of course it doesn't, it never does, whether a class is immutable or not. Most of the rest of ...

70. help with String?    coderanch.com

It can also be done with regular expressions and the replaceAll() method of String class, if you're somewhat familliar with regular expressions. public class RegexTest { public static void main(String[] args) { String test = "Welcome back back home Mike Mike Mike!!!!!!"; //Replace all duplicate words String result = test.replaceAll("\\b(\\w+)\\b(?:\\W+\\1)+", "$1"); //Replace all duplicate punctuation result = result.replaceAll("(\\p{Punct})\\1+", "$1"); System.out.println(result); } ...

71. String inequality    coderanch.com

I'm using MD5 to hash a String. Later I hash an equivalent String using the same method. However, the hashes (which are transformed into Strings for comparison) are not equal. I can also visually confirm that they are not equal. I'm wondering if transforming the String to a byte array and back again could affect the results. I'm using the String ...

72. Semicolon in string?    coderanch.com

73. at the job,do NOT excessive using of String    coderanch.com

I totally agree with Tony on this one. Additionally, using StringBuffers/Builders often makes the source harder to read (at least to me). In most cases, readability is several orders of magnitude more important than the small performance improvements you get by using the Buffer/Builder. There are exceptions, such as the mentioned concatenation in a loop. But typically it doesn't pay back ...

74. Problem with String    coderanch.com

Hi Guys. I have two strings: String s1="1,2,3,"; String s2="1 1 1 1 1 1 "; i want to remove whitespace in the s2 string. and i want to get the values of s2 string based on s1 index(1,2,3) removing , in the s1 string.. The o/p should be like this s1=1,2,3,4 s2=1 1 1 1 1 1 1 1 result ...

75. Singular string from plural noun    coderanch.com

I am in the middle of writing some XML transform logic and now I need a way to convert a String from it's plural form to it's singular form. It will be used when a bean has a property like addresses that returns a list to create:

... I don't want to iterate the entire dictionary and ...

76. Tokenizing string in Java    coderanch.com

Hi All, I am trying to tokenize a string based on either "<" or ">". E.g. If I have a string "Age 100" The o/p should be ATTR, Age, VALUE, 100 This is something similar to XML parser I am tryin to do. I have this piece of code strToken = new StringTokenizer(str,??); What Regular expression I should put in place ...

77. Strings and Wildcards...    coderanch.com

I am hoping to find a method that will allow me to check Strings with wildcards for equality. Specifically, I am trying to compare a word with several wild cards in it to a dictionary. For example, if I was to compare *a*er to several dictionary words: water would return true; laser would return true; lasers would return false; older would ...

78. Confusion creating String    coderanch.com

Basically, I'm working on a P2P simulation, and I need to set up messages to be sent from one peer to another. These messages need to be formatted in a certain way, such that bytes 0-15 of the message represent one field, byte 16 another field, etc. These messages must be sent as Strings. I'm really lost on how I should ...

79. Please help on Strings    coderanch.com

Hi, I am working with Strings and i have a requirement where in i have to count the number of occurences of a character in a String.I tried doing it with indexOf() method but could not do it.Could any of u help me with this? Its really very urgent. Thanks, in Advance P.N.Reddy.

80. String    coderanch.com

Originally posted by Jeroen T Wenting: the location in (type of) memory where the String your program receives is stored. No, actually, but this is a very common misconception. Jeroen is referring to the fact that "String literals are stored in the string pool," which is correct. But all that means is that a reference to the String is ...

81. Strings....    coderanch.com

Actuallt this toString() should be overridden in almost all the user defined classes. The purpose of this method is to give you the String representation of the Java Objects on the runtime. So, whenever you are wrtiting your classes then you should provide the toString() implementation for the same also . I hope that clarifies your doubt.

82. dynamic...strings...    coderanch.com

83. Questions regarding the article "String Literally" written by Corey McGlone    coderanch.com

Dear ranchers, I have few problems understanding the article The SCJP Tip Line Strings, Literally written by Corey McGlone. As inetrn(), gc of String is not covered in SCJP, so I am posting it here instead of SCJP forum. String one = "someString"; String two = "someString"; Quote supporting the above code... When a .java file is compiled into a .class ...

84. Problem with strings    coderanch.com

Hi, I am facing a small problem while using the substring method. I am using a simple statement as if(url.substring(url.lastIndexOf("/")+1,url.indexOf(".")).equals("Some Value")) { // do something } I tested this statement by assigning different values for url. It works fine. But when i tested it on Prod, it gave me this exception. Exception in thread "main" java.lang.StringIndexOutOfBoundsException at 0x00362c70: java.lang.Throwable.Throwable() (/usr/lib/./libgcj.so.3) at ...

85. String normalize?    coderanch.com

Just a guess - are you remembering that Strings are immutable, and therefore this method doesn't affect the original String, but rather returns a new String? If that's not the issue, I suggest posting a slightly more complete example of exactly what you're doing here, what's the expected result, and what's the actual result.

86. String    coderanch.com

The problem -- "why wasn't Hello World printed" -- is exactly what Guarav Singh pointed out - operator prcedence. The + operator has higher precedence than the == operator. Because of this, the line: System.out.println("Hello World!"+a==b); is treated identically to System.out.println(("Hello World!"+a)==b); So, what gets printed is a comparison of two references. One reference is to the string "Hello World!abc" and ...

87. String Object Creation    coderanch.com

I have a Question regarding the String Class String s = new String("abc") As per the defintion of invoking a overloaded constructor it create an object in the non pool memory and assigns it to reference variable s.In addition creates one more object abc and keep it in pool. Please correct me if something is incorrect or missed. Can anybody please ...

88. Detecting 2 periods in 1 String    coderanch.com

Hello, My JTable contains the contents of a user's hard drive with one column displaying a short file extension type description. My method that searches the Hashtable for the file extension and retrieves the description determines the file extension by the indexOf() method like so: Enumerationkeys = this.fileTypes.keys(); while(keys.hasMoreElements()) { String key = keys.nextElement(); if(!filename.contains(".")) { return "--------------"; } else if(key.equalsIgnoreCase(filename.substring(filename.indexOf('.')))) ...

89. can we have parametrized String in java ?    coderanch.com

Hi thank you for reading my post i want to know can we have parametrize String in java ? for example i need a template string like : "you have contact us from email address [param] and here is your detialed answer"+ "your transfered amount is "+ [param] "your purchased service is "+[param] ....

90. String Object    coderanch.com

Hi all Here is a chunk of a code Person is Value Object. /* Code1 */ //Code Inside some method ArrayList alPerson = getPersonList(); for(Person tmpPerson:alPerson) { if("Male".equals(tmpPerson.getSex())) { //Do Some logic } else if("Female".equals(tmpPerson.getSex())) { //Do Some Other logic } } /* Code2 */ //outside any method and inside a class public final static String strMale = "Male"; public final ...

91. why is String method called not Object method....?    coderanch.com

Hi Varma, When you invoke a overloaded method, the compiler will try to invoke the method, from which we can invoke the other overloaded method. (ie., from that method, it can invoke the other method with the same name, in this case, from the method public void myTest(String s), we can invoke the other method public void myTest(Object o)) Due to ...

92. Complicated string problem    coderanch.com

I need to get the 8 last digits of a cell phone number from a string that may contain some random text as well. The string might i.e. look like this: String senderName = "asd5fa 9 as9df asdf 5599999999sd asdf 3as4df"; How can I extract only the 8 last digits of the phone number from this string (99999999)?

93. can we create our own String class    coderanch.com

Hi ranchers, on performing > java examReview the JVM won't find the main method. Because it looks for a main method with the signature public static void main (java.lang.String [] args) but it finds only public static void main (defaultPackage.String [] args) Therefore the message java.lang.NoSuchMethodError: main The code of Nazeer will compile and run if you specify the package: package ...

94. Internationalizing Strings    coderanch.com

In my previous life as an object-oriented Pascal programmer for the Macintosh, we learned to internationalize by using full sentences like: "Sorry, you cannot ^1 because ^2". We learned not to use String concatenation, but to use parameter substitution instead. One problem that we solved is that different languages can have different word orders. String concatenation assumes a particular language's word ...

95. string delimiter    coderanch.com

Hi Ranchers, I have got a question on string delimiters. I am working on a java script which takes user input from two text areas and sends it to a servlet. I would like to concatenate as a single string in the javascript and send it to the servlet through POST method. The string values entered can be of any language. ...

96. Diff bet~n String s1[] & String s1    coderanch.com

97. String Garbage collection. Help Needed.    coderanch.com

Hi All, In java Strings are immutable objects. Whenever a new string is created it will stored in String constant pool. My dought is when string object will eligible for the GC?. If String Object is garbage collected after use. What is the use of constant pool in JVM?.(My understanding is one constant pool for the JVM) Please explain me. Regards, ...

98. Strings    coderanch.com

If those answers sound too advanced, let's look at doing the work in smaller steps. The String class has a method that will give you an array of char. The Character class has methods to tell if a char is a digit or whitespace. Can you imagine a loop through the array, checking each character, adding to counters for digits and ...

99. java String doubt    coderanch.com

100. lastIndexOf(String str)    coderanch.com