String 13 « string « Java Data Type Q&A





But this doesn't work, any advice/help on this would be greatly appreciated. thanks Justin ...

1. STRING help needed?    forums.oracle.com

Good work Matrix...you've proven that you're capable of doing a high-schooler's homework for him. Congratulations, everyone is so happy for you. ...what was the point of that? Now he won't learn anything, and will be back here next time with more homework, expecting someone to do it for him. Plus, your code sucks. Wtf is the point of all that If-Else ...

2. String class help    forums.oracle.com

Here is a some sort of algorithm to do this. 1. Read each character from a string by using char charAt(int index) fuction. refer [String Class|http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html] 2. Then determine if the character is a uppercase letter, lowercase letter or a number. using functions Method Description boolean isDigit(char ch) Determines whether the specified char value is a letter or a digit, respectively. ...

3. Voilin strings    forums.oracle.com

4. String encoding/decoding    forums.oracle.com

Part of a program I am working on reads an HTTP URL's HTML into a String object. When that HTML includes foreign languages, those characters become garbage when input into the String, and hence upon output as well. Does anyone know how to "preserve" these characters so that they can be output just as they appeared before they were input? derek ...

5. Temporarily storing a string's data    forums.oracle.com

6. Editing string from a JTextBox    forums.oracle.com

Okay. I actually managed to figure that out about 2 minutes before you posted. The problem is that even when I fix that, it still doesn't replace all cases of "a" with "b". Neither in the println or in the JLabel. Also, the first key i hit outputs a space, and the second outputs the first key. it's odd. Edited by: ...

7. all combination of string    forums.oracle.com

8. How to include '+' symbol in the string    forums.oracle.com

Dear Experts, I am using the following query: strQuery = " INSERT INTO master_table (numeric_id, full_name) values (SELECT CASE WHEN MAX (numeric_id) IS NULL THEN 1 ELSE MAX (numeric_id) + 1 END,'My Name')";* As an output for the above string the '+' is missing with gives an error as a syntax error of this query. Any suggestion will be appreciated

9. How String class works??    forums.oracle.com





10. Concerning Strings    forums.oracle.com

With your assignment String c = a you let your variable c point to the same address space as variable a. Next you assign variable c to another address space. That new assignment of c has no influence on the address space a is pointing to. Imagine two friends Carl and Albert. You give Albert the instruction to hold a glass ...

11. diff b/w String str="somestring" and String str=new String("somestring")    forums.oracle.com

hi can anybody help me in find out what is difference between String str="somestring"; and String str= new String("somestring"); see this code class Demo { public static void main(String[] args) { String s1="java"; String s2="java"; String s3= new String("java"); System.out.println(s1.equals(s2)); System.out.println(s1==s2); System.out.println(s1.equals(s3)); System.out.println(s1==s3); } } why the output is like that ?? regards rakesh rathi

12. Having trouble returning Strings    forums.oracle.com

// Output the results while(results.next()) { login = results.getString("login"); active = results.getBoolean("active"); firstName = results.getString("firstName"); lastName = results.getString("lastName"); passwordChecksum = results.getString("passwordChecksum"); lastLogon = results.getDate("lastLogon"); lastLogoff = results.getDate("lastLogoff"); deactivatable = results.getBoolean("deactivatable"); } // Close our data connection results.close(); con.close(); } catch (Exception ex) { String msg = ex.toString(); Frame f = new Frame(); f.setSize(200,200); f.setVisible(true); MessageBox message = new MessageBox(f , msg, ...

13. diff b/w String str="somestring" and String str=new String("somestring")    forums.oracle.com

hi can anybody help me in find out what is difference between String str="somestring"; and String str= new String("somestring"); see this code class Demo { public static void main(String[] args) { String s1="java"; String s2="java"; String s3= new String("java"); System.out.println(s1.equals(s2)); System.out.println(s1==s2); System.out.println(s1.equals(s3)); System.out.println(s1==s3); } } why the output is like that ?? regards rakesh rathi

14. String.toCharArray() problemo    forums.oracle.com

what do you expect? when you print an array, it is an object, and the toString() prints out a textual representation of the array. you either need to loop thru the array to print it out, or use the Arrays.toString(char[]) method available since 1.5 to print it out as a string. ~Tim

15. string manipulations    forums.oracle.com

Hi, I need a sample program just for searching whether my string two exists in string one. assume my string one is String one ="IP>10.10.10.1 and IP<10.10.10.10 and 10.100.100.27"; my string two is String two ="10.10.10.5"; i need to check whether two exists in one. i need to search in the range IP>10.10.10.1 and IP<10.10.10.10 and also with 10.100.100.27,if exists i ...

16. Prompting user input of a string.    forums.oracle.com

if(choice == 1) { String hexNums; System.out.println("Enter Hex number: "); hexNums = input.nextLine(); } else if(choice == 2) { System.out.println("Enter Binary number: "); int binNums = input.nextInt(); } else if(choice == 3) { System.out.println("Enter Binary number: "); String binNumss = input.nextLine(); } else if(choice == 4) { System.out.println("Enter Decimal number: "); int decNums = input.nextInt(); System.out.println("Enter Base wanted: "); int desiredBases ...





17. Get string from Combo Box    forums.oracle.com

18. String to Numeric    forums.oracle.com

19. manipulating strings    forums.oracle.com

20. cutting a string    forums.oracle.com

hello I want to write a simple code in jave that run on a string, if there is a '0' in the begining of the string, he will cut it, and at the end will display the new string (with out the all the '0' from the begining). if there is no '0' in the begining display the string as it ...

21. returning a different string    forums.oracle.com

22. String method    forums.oracle.com

23. Java function to get the numerals in a string    forums.oracle.com

24. Adding to a string name    forums.oracle.com

25. Separating Strings    forums.oracle.com

26. Diff between String declarations???    forums.oracle.com

27. Sepprating String in to small String...    forums.oracle.com

Becoming more familar with the String API will be a time saver for you in the long run. Here is some code to illustrate one way to do this -- class Splits { public static void main(String args []) { String txt = "hello"; char [] smalltxt = txt.toCharArray(); for (char ch : smalltxt) System.out.println(ch); } }

28. String    forums.oracle.com

Hello - please could you give me an advice? I have following string: .... String guess1="10,33,15,45,34,5"; ... Do you have any idea how to get rid of commas efficiently and put numbers into string array? I have one class solving it but it seems to be unnecessarily complicated - thank you a lot:)!

29. String to code    forums.oracle.com

32. adding with a string    forums.oracle.com

this has allbut answered by question but if i was to write a public instance that did the same thing but the other way so the string would be decreasing in length to 1. how would i code that or is it the same for as going * ** *** **** *****

33. Transferring Strings    forums.oracle.com

Sorry. Let me explain it better. I have a program that consists of multiple files, and I want to transfer a string from one file to another, rather than retyping it in the second file. That way, if I want to change the String from "blah blah blah" to "weeee!" I can just change it in the first file, and it ...

34. Using quotation in a an output string    forums.oracle.com

35. send a string?    forums.oracle.com

"Uses two different pairs of array indices--row/col an vertCount/hortCount, the latter of which are never updated. What are you trying to do here, and what do you intend those variables to mean?" Hi, thanks for the input! Sorry, I should have been more clear what I was tryiing to accomplish. Regarding to vert and hortCount, I will use those values later ...

36. string object refernce related    forums.oracle.com

37. String input / getting user response    forums.oracle.com

38. Strings loading from ResourrceBundles    forums.oracle.com

39. Integar to a String/ non-compatible    forums.oracle.com

41. String to Objec    forums.oracle.com

42. Problem with String    forums.oracle.com

Donwload Netbeans or something similar. That will save you a lot of time later. You'll given hints + can debug. It is simple (well, not to solve the problems perhaps but debug .. . However, is there a particular reason for using an array, since there's only one value now. You could run that by simply doing 1. exchanging the declaration ...

43. Beginner's question about String (conceptual)    forums.oracle.com

Hi, I started studying for exam 310-019, and I have a question regarding Strings: String is not a primtive type, rather, it is a class. You can create one string as follows: String text1 = "Testing !"; I'm in the beginning of the study, maybe I should not be asking it this time - but I thought that class type variables ...

44. pasring of the input string    forums.oracle.com

Hi, I want to convert one string to another string. here, "hello" is KEYWORD. For example, if I give input : hello(a1,D) output: (hello a1 D) if I give input : hello(m,hello(n,hello(o,X))) output: (hello m (hello n (hello o X))) if I give input : hello(a,hello(b,hello(c,hello(d,Z)))) output: (hell a (hello b (hello c (hello d Z)))) would you please help me ...

45. Beginner needing string help    forums.oracle.com

I am a new Java programmer, and I have a question for the java veterans here. I'm trying to write a program that will take a word a user inputs and checks words from a word text file to see if it can be part of the users word. ex: user's word = microwave. Words that will match from a word ...

46. pasring of the input string    forums.oracle.com

Hi, I want to convert one string to another string. here, "hello" is KEYWORD. For example, if I give input : hello(a1,D) output: (hello a1 D) if I give input : hello(m,hello(n,hello(o,X))) output: (hello m (hello n (hello o X))) if I give input : hello(a,hello(b,hello(c,hello(d,Z)))) output: (hell a (hello b (hello c (hello d Z)))) would you please help me ...

47. Doubt in Strings    forums.oracle.com

You can find the index of the (.), then use a method of the String class to cut from this index to END. *Edit: I'm sure you can use a regular expression for this too. Though, I'm not good with regular expressions as of now. Edited by: lethalwire on Nov 28, 2007 12:40 AM

48. Adding from Command Line Argument String    forums.oracle.com

49. backward string    forums.oracle.com

//************************************************************* //This is supposed to display the word entered in reverse order. //For some reason, I can only get this to work when I set the for //statement to add. When I switch it to subtract(go backwards) //it does not display anything //************************************************************* for (int i = wordArray.length; i > 0; i--) { System.out.print(wordArray); }

50. Trying to an equation in String form ("1+2-3/4 etc")    forums.oracle.com

Hi, I'm trying to take an equation in String form and get an Integer answer from it. I've been reading about String Tokenizer and Split, but I can't seem to make the jump from String "1+2-3" to int 0. Any help is very much appreciated, I've been trying to figure this out for hours. I've tried a few things including splitting ...

51. Help with returning one string from three methods of type string?    forums.oracle.com

Hello Everyone! I have three methods that get the Title, the Firstname and the Surname here are the methods: public String getAgentContactTitle() { return student.getAgentContactTitle(); } public String getAgentContactForename() { return student.getAgentContactForename(); } public String getAgentContactSurname() { return student.getAgentContactSurname(); } My Question is how can I create a method that can combine the above three get method and return a string ...

52. Object is not changing into String    forums.oracle.com

53. subscript string    forums.oracle.com

54. message.lenth() and String commands    forums.oracle.com

Hi I wonder how to imbed message.lenth() in the following code: System.out.println("Zip code"); input = scanner.next(); I?m trying to do the zip code(String) so its 5 numbers long. Also if I could have the zip code to be 5 numbers in length with a space after three numbers it would be even better. I am reading Liangs book and its bad ...

55. returning strings    forums.oracle.com

/* remove the given patron from the patron catalog and return the result * Delete patron if 1) patron exists in list and 2) patron has no books on loan * if invalid patron number return "No such patron ID number" * if valid, delete and return the partron's string representation concatenated with the result comment * * if book on ...

56. String generation    forums.oracle.com

57. strings    forums.oracle.com

You can use regular expressions to get a substring, and then use Integer.parseInt to get a number. Or you can use java.text.DecimalFormat. I suppose you could use java.util.Scanner. Probably there are some other ideas that other people will suggest as well. I'd suggest just using DecimalFormat. There's a small initial learning curve but the code should be simpler and easier to ...

58. Javabean string invoking problem    forums.oracle.com

59. Change a String    forums.oracle.com

60. Hi Problem with Strings    forums.oracle.com

61. return string    forums.oracle.com

62. Java.lang.string question    forums.oracle.com

63. Initialising String    forums.oracle.com

Hi I am still trying to learn java and having problems using the JOptionPane? I was wondering why I am being asked to initialise a String? infact even when I initialise String it quite rightly states this is an int. I cannot see what I am doing wrong. If I replace "result" with e.g. "side1Str" then it returns a number which ...

64. String question    forums.oracle.com

65. query on strings    forums.oracle.com

66. regarding sub string    forums.oracle.com

67. extraction of string    forums.oracle.com

68. extraction of string data help    forums.oracle.com

hello i have a string of data: $00VTG,45.7804,T,,M,4.0393066,N,,K,A*33 04-09-2007:05.04.48.636 $00ROT,-36.90033,A*37 04-09-2007:05.04.48.636 $00HDT,204.722,T*23 04-09-2007:05.04.48.636 $00GGA,050444.00,5609.8261856,N,01014.1781058,E,1,8,1.13,18.7638,M,43.2747,M,,*49 I want to extract the main data which is from the '$' to first comma. There are no spaces therefore i am finding it difficult without using the string methods. You first have to convert it to a char array and then extract data BUT HOW. and ...

69. Java String Class Question    forums.oracle.com

70. string class    forums.oracle.com

71. String Method    forums.oracle.com

alright, im trying to combine two string variables into a format such as firstName, lastName String format; format = +firstName"," +lastName; that is what i have, but java returns an error expecting the ; to be at the end of "". any advice on how to set two string objects between a comma would be appreciated. -java newbie

72. Href using a string    forums.oracle.com

Hi, I am trying to create a Hyperlink to open a report, the reports title is taken from a database and put into a String called URL, how do I create a link using this string. I have tried to do it with: {%>

View Report<%}%>

73. How to separate the string ?    forums.oracle.com

well to use substring you would have to know the index values of where the number starts and where it ends... one way you could do it although it's not very efficient would be to search through the string and find the first character that is between 48 and 57 (including those) since those are the ascii values that represent the ...

74. string question    forums.oracle.com

hello all i want to ask about this method.. can any one explain since i dont understand the explanation provided by the api?? can anyone give me an example for this?? indexOf(String str, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index

75. UTF-8 String issues    forums.oracle.com

76. identifying string validity    forums.oracle.com

It all of course depends upon what you define as "invalid". Having said that, for great flexibility in checking strings, matching strings, replacing substrings, etc... look into Java's implementation of Regular Expressions. This is a large and complex subject requiring quite a bit of effort if you are new at it, but the effort pays off in the long run. Have ...

77. String help    forums.oracle.com

okay, reversed.charAt(0) does not actually translate to the variable that stores the character in the position 0. It is a METHOD that returns the character in position 0. Therefore, you can't assign to it. To use a word from c++ vocab, you need to have an l-value for assignment, and reversed.charAt(0) is not an l-value. Furthermore, I'll save you from spinning ...

78. String issues    forums.oracle.com

Hi. I am having some uses writing a class for one of my java courses. For this assignment I am supposed to create a class that accepts a string array of three elements that are supposed to be three characters long. I'm running into several issues with my for loops and String variables that I define and I was hoping if ...

79. string.multipleReplaceAll    forums.oracle.com

80. String problem...    forums.oracle.com

81. weird String problem.    forums.oracle.com

82. Get whole arguments string    forums.oracle.com

/** * append the elements of array into one string, seperated by FS * @param a - an array of strings to join together * @param FS - Field Seperator string, optional default=" " * @example * String[] array = {"Bob","The","Builder"}; * System.out.println(join(array); * --> Bob The Builder * System.out.println("String[] array = {\""+join(array, "\",\"")+"\"};"); * --> String[] array = {"Bob","The","Builder"}; */ ...

83. Introduce ctrl-p in a String    forums.oracle.com

84. Running Strings as Commands    forums.oracle.com

I have a strange question which I have been unable to answer for myself. Does Java have any way to dynamically run a command that is given in the form of a String? Say for example: runCommand("System.out.println("Test"))? I know that other languages are able to do this, the one I code in at work will allow it, for instance. I just ...

85. existence of a string in another    forums.oracle.com

86. Strings    forums.oracle.com

Oh so you can only change the string's value once. Depends what you mean by "string's value." You can never change the contents of a String object. Strings are immutable. You can change the value of the variable as many times as you want, since it wasn't declared final. Note that variables never hold objects in Java. They hold references. So ...

87. strings    forums.oracle.com

In the case of string literals--stuff in "double quotes" in your code--it will be the same object. "rome" and "florence" go into the constant pool when your class is loaded, and anywhere "rome" or "florence" appears in your code it will refer to that object in the pool. For strings that are not in the constant pool--those that come from, say, ...

88. strings    forums.oracle.com

89. string seperation    forums.oracle.com

I have this string.. String a ="Today is Monday, Tomorrow is Tuesday, Yesterday was Sunday, the day before Sunday was Saturday" If i want to have output like Today is Monday Tomorrow is Tuesday Yesterday was Sunday How can i do that?? I think..the first step is to find commas... Would you please guide me?? Thanks,

90. Need String help!    forums.oracle.com

I wanted to learn Java, so I bought "Java for Dummies 4th Edition". I think it's a little outdated, but seems fine. I'm creating a text-based game where the user inputs a question, and then that text is put into a string. The problem is, the string won't accept spaces, and only takes the first word. I was thinking about having ...

91. Adding strings?    forums.oracle.com

92. String assignment ?    forums.oracle.com

Hi, in the following code: public class Test { public static void main(String[] args) { String s = new String("Welcome to Java"); Object o = s; String d = (String)o; System.out.println(o + s + d); } } Both strings and the object are referring to the same string object., and the println shows 3 "Welcome to Java" 's. I don't understand ...

93. String entered when prompted, from the command line    forums.oracle.com

Hi! Maybe one of the best cases to do this is: if (userName != null && userName.trim().compareToIgnoreCase("ConneX") == 0) ... First you evaluate the string is not null and then the trim() method evaluate the string without spaces and then compare de string ignoring the string case. (The compareToIgnoreCase method returns a int value 0 if the value is the same ...

94. String Question    forums.oracle.com

95. New object (with string)    forums.oracle.com

Hello, I have a function which is getting as an input a string variable and needs to create an new object that has the same name as the input string. How can I do it? For me the main question is why you want to do this? What difference is the name of the as long as you can find the ...

96. Striping out comas in a String    forums.oracle.com

97. Problem with strings    forums.oracle.com

I did not get the logic of how to compare the characters of two strings. What i was thinking was I will convert both the strings into array and then compare each element of one array with the other but how to get the remaining characters in the main string. will this be fine or there is some simpler method to ...

98. String object question    forums.oracle.com

99. question about string    forums.oracle.com

100. String Indexoutofbounds    forums.oracle.com