• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionpane and strings  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Conceptually, can someone please explain to me how strings work? I've been taking an intro to java course, I've become obsessed with it, but certain things just don't click with me. I know I can use charAt for specific characters and what not but I don't get how Strings really work or how I can manipulate them. I'm not asking for a bunch of links, especially to Oracle, because when I look at those I still don't understand it. If someone enters eighteen words on joptionpane I have literally no idea how to view them as eighteen different things or express them in such a way. I don't care if I'm viewed as the biggest idiot to ever post on this site but I feel like converting strings to things that can be understood by the compiler, separating them, and manipulating them is something anyone learning java in the future is going to struggle with.

There are so many super intelligent people on this forum. What do you feel helped you grasp the deep nature/structure of java language? I feel like I'll complete things, they work, but I just don't get really why they work.

 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan Bishop wrote:I know I can use charAt for specific characters and what not but I don't get how Strings really work or how I can manipulate them.

That's quite a big question, because there are LOTS of ways to manipulate Strings. However, for the example you cited, use String.split(regex) - specifically:
String[] words = myString.split("\\s+");
which will put each word into an element of the String array 'words'.

Explanation:
1. "Words" are normally delimited by whitespace.
2. "\\s" means 'a whitespace character'.
3. The "+" means '1 or more'.
so the split() call will return the substrings between blocks of whitespace characters as an array.

I'm not asking for a bunch of links, especially to Oracle, because when I look at those I still don't understand it.

Then you need to read the tutorials, because explanations of this sort are simply too big for a forum like this. Once you can get your head around them, the API docs are normally the ideal way to get the info you want, so I'd spend some time learning how to use them because you simply cannot keep all that information in your head. I've been using Java for 12 years now, and I ALWAYS have the API page open when I'm working.

There are so many super intelligent people on this forum.

I've never been accused of that. Guess you can fool some the people some of the time...

Winston
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!