I have a String text "Welcome!to java@";  I know how to convert it to receive array [Welcome, to, java]      String[] aaa = text.split("[\\p{IsPunctuation}\\p{IsWhite_Space}]");     System.out.println(Arrays.toString(aaa));   //priinting   But I need to include punctuation. I need to receive [Welcome, !, to, java, @]  Anybody know who to receive it ?  The reason why I need to do it, because i have a randomise(char[] cw) method, which is tweaking words for me. However that method is going crazy when punctuation is included  public void randomise(char[] cw)      {         for (int i = 1; i &lt; cw.length-1; i++)          {             //my range             int range= (int)(Math.random() * (cw.length - i - 1));              //swap index             int index=i+range;              //swap             char temp  =  cw[i];             cw[i] = cw[index];              cw[index] = temp;          }         System.out.println(cw);      }   Thanks for reply
97702
I'm trying to split a string with all non-alphanumeric characters as delimiters yet Java's String.split() method discards the delimiter characters from the resulting array. Is there a way to split a string like the "\W" regex pattern does, yet keep the delimiters?
7406
Java has a convenient split method:  String str = "The quick brown fox"; String[] results = str.split(" ");   Is there an easy way to do this in C++?
4602
Example (note the case):  string s = "Hello world!"; String s = "Hello world!";   What are the guidelines for the use of each? And what are the differences?
14769
I need to concatenate two String arrays in Java.  void f(String[] first, String[] second) {     String[] both = ??? }   What is the easiest way to do this?
118921
I swear I've seen someone do this, but I can't find it in the various lists of shortcuts.  Given:  String s = "A very long ............................ String";   Is there an Eclipse shortcut to turn it into:  String s = "A very long ............................ "      + "String";
102259
I need to search a string in the string array. I dont want to use any for looping in it  string [] arr = {"One","Two","Three"};  string theString = "One"   I need to check whether theString variable is present in arr.
37844
Is there a good reason why there is no Pair&lt;L,R&gt; in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own.  It seems that 1.6 is providing something similar (AbstractMap.SimpleEntry&lt;K,V&gt;), but this looks quite convoluted.
22890
In Java, I have a String and I want to encode it as a byte array (in UTF8, or some other encoding). Alternately, I have a byte array (in some known encoding) and I want to convert it into a Java String. How do I do these conversions?
5691
Is there a better way of getting this result? This function fails if num has more digits than digits, and I feel like it should be in the library somewhere (like Integer.toString(x,"%3d") or something)  static String intToString(int num, int digits) {     StringBuffer s = new StringBuffer(digits);     int zeroes = digits - (int) (Math.log(num) / Math.log(10)) - 1;      for (int i = 0; i &lt; zeroes; i++) {         s.append(0);     }     return s.append(num).toString(); }
92412
I have an array of 1000 or so entries, with examples below:  wickedweather liquidweather driveourtrucks gocompact slimprojector   I would like to be able to split these into their respective words, as:  wicked weather liquid weather drive our trucks go compact slim projector   I was hoping a regular expression my do the trick.  But, since there is no boundary to stop on, nor is there any sort of capitalization that I could possibly key on, I am thinking, that some sort of reference to a dictionary might be necessary?    I suppose it could be done by hand, but why - when it can be done with code! =)  But this has stumped me.  Any ideas?
13332
I am trying to use a  as input and then creating a query with it - so I need a .    I was surprised to find that it couldn't do the conversion implicitly or explicitly - but I don't even know how I would do this, as the Java API is still fairly new to me.
17519
I have a string containing the , and I need to convert it to a Java Date object.  String date = "1081157732"; DateFormat df = new SimpleDateFormat(""); // This line try {   Date expiry = df.parse(date);  } catch (ParseException ex) {   ex.getStackTrace(); }   The marked line is where I'm having trouble. I can't work out what the argument to SimpleDateFormat() should be, or even if I should be using SimpleDateFormat().
33838
I have a string (e.g. "AABBCCDDEEFF") and want to split this into an array with each element containing two characters - ["AA", "BB", "CC", "DD", "EE", "FF"].
10097
Does Java have a built-in way to escape arbitrary text so that it can be included in a regular expression? For example, if my users enter "$5", I'd like to match that exactly rather than a "5" after the end of input.
41680
If I have the following string:  string s = "abcdefghab";   Then how do I get a string (or char[]) that has just the characters that are repeated in the original string using C# and LINQ. In my example I want to end up with "ab".  Although not necessary, I was trying to do this in a single line of LINQ and had so far come up with:  s.ToCharArray().OrderBy(a =&gt; a)...
20129
I'm learning JavaScript and while browsing through the jQuery library I see : (colon) being used a lot. What is this used for in JavaScript?   // Return an array of filtered elements (r) // and the modified expression string (t)    return { r: r, t: t };
116296
Anytime I have to handle dates/times in java it makes me sad   I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.  "Exception in thread "main" java.lang.Error: Unresolved compilation problem:  The method setDate(int, Date) in the type PreparedStatement is not applicable for the arguments (int, Date)"  Eh WTF?  Here is the offending code.  for(int i = 0; i &lt; flights.size(); i++){      String[] details = flight[i].toString().split(":");      DateFormat formatter ;      formatter = new SimpleDateFormat("ddMMyyyy");     Date date = formatter.parse(details[1]);       PreparedStatement pstmt = conn.prepareStatement(insertsql);     pstmt.setString(1, details[0]);     pstmt.setDate(2, date);     pstmt.setString(3, details[2] + "00");     pstmt.setString(4, details[3]);     pstmt.setString(5, details[4]);     pstmt.setString(6, details[5]);     pstmt.setString(7, details[6]);     pstmt.setString(8, details[7]);     pstmt.setString(9, details[8]);     pstmt.executeUpdate();  }