String 11 « string « Java Data Type Q&A





1. Strings    coderanch.com

2. String    coderanch.com

String s3="hello"+"world"; String s4="helloworld"; System.out.println(s3==s4); Please tell me what happens when we concatenat two string literals using + operator. What will be the output of SOP. If false then why? How many Objects are getting created here? are objects created in string literal pool eligible for GC? is any object created above is eligible for gc?

3. Generate string    coderanch.com

first, the terms 'permutations' and 'combinations' are well defined terms, and are mutually exclusive. or I guess technically, the set of combinations is a subset of permutations (unless i got that backwards). So, before we can do much else, tell us what you really want. Combinations are where the order doesn't matter, so "ABC" is considered the same thing as "CBA". ...

4. Sanitizing String in Java.    coderanch.com

Strings are strings -- just a sequence of characters. And there are no rules as to what they can contain. A "string literal" is a way of expressing the value of a string in code. The escaping mechanism is necessary so that characters that could not otherwise be expressed in the value can be expressed. For example \n to represent new-line. ...

5. String Builders    coderanch.com

Hi all, I have two questions to ask- 1.In a StringBuilder class,when we create it's object,we pass a string literal as parameter.Does this literal also goes in the constant pool? 2.During chaining of methods in case of Strings,such as "x.concat("def").toUpperCase().repalce('x',"X")",if the temporary objects created are lost,how come methods are invoked on them when they are lost.i.e if x.concat("def") creates a object ...

6. Does String.startsWith() support multiple string?    coderanch.com

If you only want to check for the presence, instead of also retrieving the value, you can use a regular expression in combination with String.matches. Check out the Javadoc page of java.util.regex.Pattern for more information. Don't forget to let your regex end with ".*", because String.matches looks for a match of the entire String.

7. String Input and Bubble Sort    coderanch.com

I am trying to create a program that receives user input to build a string array. Then I want the string of random letters sorted in order of the abc's. I previously built a program using bubble sort to sort an initialized array of numeric values of type int. This program worked out fine, so as I do with most programs ...

8. Strings Problem    coderanch.com

9. Is it possible to create an Object from a source code String?    coderanch.com

Hello, moose-people. I come in peace. This is my first post here and I have a question about dynamically creating objects. Let's say I have a String containing something like "new Date()". Is there a way to evaluate that string and return an Object out of it? I have looked at the javax.tools package but I can't see any way to ...





10. creating uuid's or similar based on a string    coderanch.com

Hi all, I have written a web crawler that crawls tube sites. Each tube it finds it grabs the thumbnails for to show in search results and these are stored on my server. At the moment for each tube I find I create a folder name based on a random uuid and store the thumbnails in that folder. I then store ...

11. String Object    coderanch.com

Hello Good Morning Everyone... I want to ask question regarding String.... We can create String object with two different ways String string = "Rishabh"; Here, It creates one reference variable string and one String Object in Pool Memory. String string = new String("Rishabh"); Here, It creates one reference variable string and one String Object in Normal (Non-Pool) memory and other object ...

12. String Objects    coderanch.com

13. String processing    coderanch.com

Hello I want to write a method, that when presented with a String, will be able to do the following: 1. Remember from where it was sent (arguments?). 2. Be able to translate the data to an integer and send it back to the appropriate integer back from where it was sent. 3. Be able to enter console mode, where the ...

14. String analyzing    coderanch.com

What is the best way to analyze a string? I have a string that contains three words. Using if statements, I want the words to have different meanings in different contexts. In the order each happens, I want the method that analyze the string to do the following: 1. Verify that the string is in the required format (two or three ...

15. string comparassion problem ?    coderanch.com

i m comparing the txt in the component with the string name which has a value "a" so i m typing the same letter a in the text field but the code is executing the else part even though the string name and the value return from the textfield is same ie "a" but this code returns true means "ok" when ...

16. String to Sealed Object    coderanch.com

Hi friends. I m stuck with this while doing my project. I tried to encrypt the data using RSA and sealed it using sealed object, while sending it over the network as xml file i converted sealed object into a string. At the receiving end i parsed the xml string file using DOM Parser and i cannot figure a way to ...





17. Doubt in String class    coderanch.com

class Display { public static void main(String a[]) { String s1 = new String("AA"); String s2 = new String("BB"); System.out.println(getString(s1, s2)); System.out.println("s1= " + s1 + " s2 = " + s2); } public static String getString(String s1, String s2) { s1 = s1 +" "+ s1; s2 = s2 +" "+ s2; return s1 +" "+ s2; } } Output: ...

18. how can i separate string?    coderanch.com

A college course can be described using three components: , where represents an empty space. Write a Java program that obtains a course string, and then splits and prints the THREE components of the course. for example ~ ABC 12345 Spanish Studies the users can type what classes they want. how can i seperate them to : Enter ...

19. How to alternate between two sets in a string?    coderanch.com

I'm trying to write a method that accepts a string of names followed by integers, and the names alternate between boys and girls. For examples: "Mark 41 Jennifer 22 Daniel 49 Jessica 67 Joshua 87" The output should be: 3 boys, 2 girls boys sum = 177 girls sum = 89 I'm having trouble just figuring out first of all how ...

20. Java string help please    coderanch.com

Hi, I need some help... I have a java array list. while iterating through list I want to create a string of the element seperated by : How can I do that? List arrayList = new ArrayList() Iterator iterator = null; iterator = compName.iterator(); while (iterator.hasNext()) { String name = iterator.next(); // Here the string I want to build shold be ...

21. String composing problem    coderanch.com

Hello Friends! I have problem with String composition. I want to compose a string with a '+' operator. But the result is not what I would expect. Here is the example: String date = "16" + "." + "11" + "." + " 2011"; I expect to get a string date written in this form: "16.11.2011", but unfortunatelly the result is ...

22. hide query string    dbforums.com

23. string compression    dbforums.com

I have an applet which requires a moderately large hashmap ( 1/2 mb ). The hashmap has a key that's a small string and returns an integer. The sting looks something like "k23k32|m15", "m1|k32", "m3|m7" etc while the number could be anything. I was thinking of putting the whole hashmap into a string and then compressing the string down - putting ...

24. String - Input    dbforums.com

25. formulation quotation mark in String    dbforums.com

Hi, I would like to form contains inquiry (phrase search) in MS SQL Server fulltext. But there are Probleme in the formulation string with the quotation mark " " and ' '. How may I formulate that ('"Dresdner Bank"') correct in java? I think, this ist the java problem. ResultSet rs = wstmt.executeQuery("SELECT titel, author, datum, text_typ FROM texttable_intern WHERE CONTAINS ...

27. drawing a string vertical    java-forums.org

28. Drawing strings in Java    java-forums.org

Hello, I have some questions regarding drawing strings in Java, more exactly regarding the determination and measurement of the size of strings. The API says that the unit of the parameter size in the constructor Font(String name, int style, int size) is point. But how is the relationship between points and pixels in Java? I found serveral resources on the web ...

29. String to bitmap generation    java-forums.org

Hi I try to generate a bmp file. The input data will be a String in Unicode like String s = "Hello world"; The output will be a bmp file of hight and width which will have this text on it. The font used to generate bmp should be also a parameter. Now my quastion: is it possible to generate this ...

30. Set not working '-' as unique string    java-forums.org

Hi Friends , Few Days before I faced an issue , I used Set to store only unique strings for one of my requirements but the strange thing was Set was allowing me to store "-" twice . As in it was not considering the hyphen as unique string , I could not find any apt explanation for this behavior , ...

31. Strings and delimeters    java-forums.org

HI people, I am trying to get user input in a table in the form 00:00 with this in mind, the input has to be returned as a string for it to be in that format. Am thinking of using delimeters to seperate the two values and if the user attempts to input int or double an error shoud be displayed. ...

32. Java String    java-forums.org

I think first of all you should have a design for this. Do you have any? Steps are something like this, in a simple way. 1. Have to read the user inputs from the user. 2. Have to detect each key-stroke. 3. Have to count all valid(means that key is type or not) key-strokes.

34. how to at strings to a string like a table    java-forums.org

i didnt explain good i am printing through a printer a string also the string is printed to the cmd to System.out.print(string) the same string has diferent form on the paper and diferent on the cmd i want the form on the paper to be the same as the the string output on the cmd

35. If statements, input, and strings    java-forums.org

I'm trying to write a program that has a user input a month.. ex. October and have it output 10..but im having some trouble..it wont let me do if (month = october) system.out.println("10") else if (month = november) system.out.println("11") you guys get the idea...but i cant do month = october as an if statement...Im not sure how i would go about ...

36. String to an object?    java-forums.org

Hello, I am very new to Java so please forgive me! I am doing some tutorials on associating classes. I have 2 classes; 1 called User, the other called Email. A 'user' has an 'email' address. I need to do a setEmail method in the User class, but I am having a problem. Here is a bit of my code... My ...

37. Help with my mess...using multiple delimiters and string splits...    java-forums.org

Alright what I need to do is take a text file that contains data formatted as so: 5 4 + 2 i -5 + -23 i etc... And what I need to do is read in these complex numbers into my program and then separate them so they will read as 4 2 so that I can compare the 2 integers ...

38. Do While with String varification    java-forums.org

boolean inputCorrect = false; do { System.out.println("Enter offence type (\"m\" / \"s\"): "); offenceType = input.next(); if (offenceType.equalsIgnoreCase("m")) { offenceFee = minorValue; finalMinorOffences = finalMinorOffences + 1; inputCorrect = true; // set inputCorrect variable here! } else if (offenceType.equalsIgnoreCase("s")) { offenceFee = SERIOUS_FINE; finalSeriousOffences = finalSeriousOffences + 1; inputCorrect = true; // set inputCorrect variable here! } finalFee = finalFee + ...

39. create object with name from string    java-forums.org

You might want to consider using a JTable and display the data within that. Then the data is findable, sortable and editable. Otherwise, you could use OOPs technique of encapsulation and make a class that creates a JPanel which holds the attribute JLabels for one and only one Character as well as a related JButton, and have that button's actionlistener display ...

40. Two identical strings are not identical...    java-forums.org

...apparently. Of course I must be just doing something stupid. Hello all, I'm new to Java and new here too. Hope to get an answer to this; I've been learning java for a few weeks now and have been lucky enough to get an Internship position but I don't want to keep bothering my boss. I have tried unsuccessfully to figure ...

41. need help in string to input    java-forums.org

import java.util.Scanner; public class TestString { public static void main(String[] args) { String STS = " STS"; int stackSize = STS.length(); Stack theStack = new Stack(stackSize); for (int j = 0; j < STI.length(); j++) { char ch = STS.charAt(j); theStack.push(ch); } while (!theStack.isEmpty()) { char ch = theStack.pop(); System.out.println(ch); } } }

42. friend... A doubt in string concept    java-forums.org

friend.... dis is kArtik... a very very smAll doubt....:) im comparing two strings..... sAy str1,str2. if any chArActer of str1 mAtches to str2, im going to delete that chAracter from both strings..... eample- befor execution- str1=ghjm str2=mjfg after execution- str1=gh str2=f how could i Acheive dis.....? plz send me code, And specify Appropriate string method to use in our code....:) thankx... ...

43. My own string class    java-forums.org

This is my first time working in java, my only other programming experience was a semester long class in C++. Our first project in java is to basically mimic the String class that already exists in java. I have been having an issue with creating one method, to return the length of the user's string. The way I'm thinking of doing ...

44. WordSearchAPI cannot be applied to (java.lang.String)    java-forums.org

public boolean executeKey1(String word, String sequence) { PicX pword = new PicX(25, word); PicX psequence = new PicX(18, sequence); PicX passin = new PicX(43, pword.toStringWithSpaces() + psequence.toStringWithSpaces()); Boolean returnstatus = new Boolean(false); boolean returnVal = false; Object[] objs = { returnstatus, passin}; try { returnVal = runtime.cobcall_boolean("JAPISL211SEARCHKEY1", objs); } catch (COBOLException ex) { System.out.println(ex.toString()); } catch (Exception ex) { System.out.println(ex.toString()); } ...

45. It is possible in Strings..?    java-forums.org

46. Trouble with Tokenizing String    java-forums.org

Hello! I am working on a program that performs mathematical operations on a complex number. I have all the code compiled and am trying to get through the run-time errors. My hunch is that I am doing something wrong with the fromString method since regardless of how many complex numbers I input (in postfix), it only returns the first complex number. ...

47. String    java-forums.org

48. String quizes here please    java-forums.org

Hi, here are the questions, plz write the answers by using 'QUOTE' my post 1. System.out.println("2" + 3); // Output what? 2. System.out.println(2 + '3'); // Output what? 3. System.out.println(1 + '2' + "3"); // Output what? OK, today is these, answer these questions before run it on your PC. Good luck!

49. String regioMatches help    java-forums.org

50. string prompt doesn't appear in showInputDialog    java-forums.org

I have the following code... newSpecialAbilityName = (String) JOptionPane.showInputDialog(parentGUI, "Enter name of Special Ability to add.", "xyz", JOptionPane.PLAIN_MESSAGE, null, null, ""); The result is a dialog box that doesn't display the string, "Enter name of Special Ability to add." Also, only an OK button appears. There is no Cancel button. I adapted this from a Sun tutorial, and their example shows ...

51. Problem with creating a string bar chart    java-forums.org

System.out.print(bar1(num1)+" "+bar2(num2)+" "+bar3(num3)); } public static int bar1(int num1) { for (int i = 1; i <= num1; i++) { System.out.print("** "); System.out.println(); } return num1; } public static int bar2(int num2) { for (int i = 1; i <= num2; i++) { System.out.print(" "); System.out.print("** "); System.out.println(); } return num2; } public static int bar3(int num3) { for (int i ...

52. How to create dynamic string object???    java-forums.org

53. Problem in String object    java-forums.org

when an object is passed as an argument in a function,it is passed through object reference not value.right.!! but when i apply it to String object it doesn't work see below code: class string { static void change(String str) { str="java world"; } public static void main(String s[]) { String str1="java"; System.out.println(str1); string.change(str1); System.out.println(str1); } } /* ========= output:-> ========= java ...

54. Change to string    java-forums.org

55. String Object Creation    java-forums.org

56. copying a part of a string and moving it to the end of the string?    java-forums.org

package package10; import javax.swing.JOptionPane; public class XlatorMain { /** * @param args */ public static void main(String[] args) { // if you don't have one (or more) of these translators implemented, jut comment out the line int [] translator = { Xlator.UNCHANGED, Xlator.LOWERCASE, Xlator.UPPERCASE, Xlator.ALTERNATE, Xlator.PIGLATIN, //Xlator.SWEDISHCHEF }; String input = JOptionPane.showInputDialog(null,"Enter the text for translation: "); while (input!= null) { ...

57. Repalcing '?', '('..... in a string    java-forums.org

58. Problem Showing A Big String?    java-forums.org

I have some urgent work to produce for tomorrow. Unfortunately I have just noticed a major bug(!) I have been building a text analyser. One of the features is that it loads text from file and then places the text onto the screen in a JTextArea. My problem is, is when the file is above a certain size the Java program ...

59. The method myFunction(String) is undefined for the type    java-forums.org

man oh man, yeah that was the issue. I though it was rebuilding each save but I guess not. I am using MyEclipse so I just went to project > clean and that took care of it. While that worked, is that the correct method? I am in the learning stage right now.;).

60. Concatinating strings help    java-forums.org

import java.util.*; public class Ex7{ public static void printPassList(Vector v){ Vector vec = new Vector(); vec = v; String str =""; int vecSize = vec.size(); for(int i=0;i=50) && (mark <70)){ str += "pass"; } else if(mark >= 70) { ...

61. String question    java-forums.org

62. How to get Treepath from String    java-forums.org

63. i need help with my excercise about strings please :(    java-forums.org

Hellow there i need help from anyone who have time with this excercise *am using jcreator pro demanded points i should write a program to enter a String of single or multiple words in length. (Their entry may contain spaces, digits, and/or punctuation characters.) The program will then work out the modified version of the user's String as follows. Starting with ...

64. Meaning of "String..."    java-forums.org

65. String/ object creation/ efficiency    java-forums.org

Well, if that str is just a local variable no other threads can touch it so theoretically (if the compiler were that smart) those three toString( ... ) could've been collapsed to just one; but then again: the compiler doesn't know that the toString() method is referential transparent so it duly generates three method calls ... kind regards, Jos

66. String != String (????)    java-forums.org

Java Code: package utilities; import java.io.File; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JTextField; public class fileChooser { /* Constant objects */ private final static JFileChooser fc = new JFileChooser(); /* Open File and Return Absolute Path ('Path/to/file.fasta') */ public static void openFile(JButton button, JTextField textField, String extension) { int returnVal = fc.showOpenDialog(button); if (returnVal == JFileChooser.APPROVE_OPTION) { fc.setFileSelectionMode(JFileChooser.FILES_ONLY); File file ...

67. Input output without string class    java-forums.org

I agree with JosAH its a pretty stupid question. However, i suppose they are wanting you to make an array of chars - basically what a string is. You can read them using data input stream readChar() and output them using a print stream. It would be awkard to manipulate them though, Strings make it a lot easier. Berkeleybross

68. The $ symbol in a string    java-forums.org

Hi Guys, Im trying to return the value of a substring stored between two other strings. lets say String Bbeg (beginning) and String end (end) the problem is my pattern search wont allow for the String beg value ("<$") and its really beginning to annoy me. Is there an easy way around this? regards S

69. How to take a string litterally.    java-forums.org

I'm brand new to Java. I'm used to programming in C#, where, if a string literal has certain special characters, I can precede it with @ and the compiler takes the string literally without trying to interpret the special characters. I can also escape the characters with \, but the @ allows me to avoid that. Is there something similar in ...

70. how to call class using String    java-forums.org

71. Why dosent return new string    java-forums.org

How to reload a class? Here's a example Class Car.getCar(); returns car name string from a file. Car car = new Car(); car.getCar(); returns Honda MODIFIE CAR FILE(REPLACE HONDA WITH BMW) car modifCar = new Car(); modifCar.getCar(); returns Honda if I restart my app then it returns bmw. Why dosent the second one return bmw?

72. Weird Behaviour of String    java-forums.org

Hi there, I have a tricky qn. I have a string declared like the following: String a = "\010"; and if i do a toCharArray() i will get a char array of size 1 which is what i want. however when i did a scanner like the following: String input; Scanner inputReader = new Scanner(System.in); input = inputReader.nextLine(); and when i ...

73. Help with String I/O    java-forums.org

import java.util.Scanner; class Momentum { public static void main(String [] args) { char c1; String s1; Scanner reader = new Scanner(System.in); while(c1 == 'y') { double mass; double velocity; double momentum; System.out.print("Enter mass in kilograms (kg): "); mass = reader.nextDouble(); System.out.println(); System.out.print("Enter velocity in meters per second (m/s): "); velocity = reader.nextDouble(); System.out.println(); momentum = mass * velocity; System.out.println("The object's momentum ...

74. String question    java-forums.org

75. DSN less connection strings for ODBC    java-forums.org

To obtain an ODBC connection, creating a DSN is not always necessary. It can be done in the following way for sybase iq db: String url = "jdbc:odbc:Driver={Sybase IQ};Compress=NO;" + "TCPIP{host=;port=};" + "AutoStop=YES;ServerName="; Connection con = DriverManager.getConnection(url, , ); Same can be done with most of the databases. But the property names differ for different databases. Best way to find out ...

76. If Else Statement using String    java-forums.org

Hello, I am having some issues with a small program I have to complete for my Java class. Basically, the program will determine a worker's raise based on their current salary. It will first ask for the current salary, and then for a performance rating (Excellent, Good, or Poor). An Excellent rating will receive a 6% raise, a Good rating will ...

77. Problem with multiple string in classes    java-forums.org

OK i have this program for a hotel check-in system for my CS class. I know i need to do things myself, and i have come far already, but still have the following problem. However i have a problem that i can't seem to fix. Right now one can input a surname and lastname. both strings will be combined and put ...

78. Using String    java-forums.org

79. Can someone give a sample for JOption with 2 strings?    java-forums.org

The OP should read the API documentation for that class; it's all in there. The OP has polluted this forum more than enough with repetative questions about this class without showing any effort (nor creativity) to solve the 'problems' (mind the quotes). I'd say back to the API documentation. kind regards, Jos

80. pasre string to time    java-forums.org

81. Strings Lower/UpperCase    java-forums.org

Hi I'm just screwing around with strings. I just managed to reverse a string using a "for" loop. I managed to convert chars from lower to uppercase and vice versa, but now I can't manage to convert particular chars in the string from upper to lowercase. For example let's say, I want to convert "HaLLoWeeN" to "hAllOwEEn", do you have any ...

82. Strings Problem    java-forums.org

Hello guys, I'm in APCS and right now we're working on a Sun Microsistems tutorial exercise that involves making a library program. It's really simple, you only have to show the books that you have on the shelf, the ones on loan, check in, check out, add and remove books. They provide us a with a Library Class that has every ...

83. Basic String Help    java-forums.org

Hello Everyone! I am currently working on a lab for APCS and needed some guidance on Strings. The lab asks for a license plate to be inputed by the user, and I am asked to add up the ASCII values of the letter part of the plate to the number part. Here is what I have so far: System.out.print("Please enter the ...

84. saving a string data.    java-forums.org

I wanted to add a save option to my program. I made a "save()" methode and in that methode I rewrote all the data I need to save into one (big) String. Now I want to find if there is a text file in the same map as the program with the name I give my text files (for example "saved ...

85. Why would a String class need a wait() method?    java-forums.org

I now understand that every class has Object as a base class. This is great but I noticed that Object has several wait() methods, which means every class have these methods? If so, why would a String class need a wait() method? If this is part of an entire concept or design philosophy in which even a basic type needs to ...

87. Java String Digit Question    java-forums.org

88. String Builder    java-forums.org

StringBuffer is used to store character strings that will be changed. It automatically expands as needed, when you adding new. String objects not like that, cannot be changed. StringBuilder was added in Java 5. It is identical to StringBuffer except that it is not synchronized. Means you cannot access it from more than one thread at the same time.

89. string program in java    java-forums.org

i have a program with string = "I Came I Saw I Left" i want a program to 1> remove duplicatesCame Saw Left> 2> output should be like I saw,I Left,I Came public class StringTest { public static void main(String[] args) { // TODO Auto-generated method stub String s= "I came I saw I left"; String[] words = new ...

90. Understanding String vs new String()    java-forums.org

== tests to see if the object referred to by one variable is the same object as that referred to by the other variable, and with Strings (and most other objects), you really don't care about this. What you want to know instead is are strings themselves, the characters, order of characters and case the same for one String vs another, ...

92. String help!    java-forums.org

Alright so I just began taking a class learning about entry level java programming, and so far decently good but I have run into a problem writing a homework program. In my head this program seems to work. However in eclipse it keeps telling that i can't convert this char to a string. I have to follow these instructions: copySubsequence(): this ...

93. SIMPLE String problem    java-forums.org

I'm writing a textbase(simple) game for my Javaclass, but I have this stupid little problem that I don't find the reason for: I've got a class Player with a field String name and the method: getName() {return name;} (pretty standard) and the class game has this piece of code in it: private void createAreas() { ..... markt = new Area("sometext","blablabla \n#Barry#: ...

94. Is the Head First Java book wrong about Strings and GC?    java-forums.org

PS, it would seem to me that if all one-use strings stayed around forever, then every single java app that reads and writes many strings would bloat up. I have not found this to be the case at all, so I think the book is either incorrect, or is pointing at something that is poorly described.

95. A String method that checks to see the data is numeric?    java-forums.org

Yeah, simply try Long.parseLong() on the text they entered (you'll need a try catch). If an exception is thrown, then there was something other than a number and you can notify the user. If no exception is thrown, its a number. This will work on anything up to Long.MAX_VALUE. If you're dealing with much larger numbers, then you might try using ...

96. Need help with Strings    java-forums.org

This is pretty urgent, but I basically need a few small methods to be made and have been working for several hours just trying to see where to start. Id rather keep it private, so if anyone can help me id be more than happy to donate money via paypal to you. Thanks.

97. string and condition problem    java-forums.org

98. string    java-forums.org

99. String object Help    java-forums.org

100. How do initialize these Strings?    java-forums.org