English 中文(简体)
在 Java,你如何用一句话加以描述?
原标题:In Java, how do you parse through a single word string?
  • 时间:2010-05-04 22:13:29
  •  标签:
  • java
  • string

我试图用一句话来形容。

你们怎么会把最后一封信分配给一个变数?

我想利用斯堪的班子来平整字,使每封信成为阵列中的一个要素,但斯堪的内尔(S堪的纳)似乎只是用整句话,而不是用个别信件。

任何帮助?

EDIT: Thanks so much for your help guys. It looks like I was overthinking it as I didn t know about charAt(). Much simpler now. Also, i m amazed at how fast the responses are on here, it s a god send especially as I ve got an assignment due in tomorrow and I think I might be in for an all-nighter.

问题回答
String str = "the rain in spain";
System.out.println(str.charAt(str.length() - 1));

就像你重新思考。 为什么不这样做

String x = "abcde";
char y = x.charAt(x.length() - 1);

你们可以使用长处和果园方法。 下面是你开始学习的一个例子:

String test = "ABC123";

for (int i = 0; i < test.length(); i++)
{
    char myChar = test.charAt(i);

    // etc.
}

公正使用替代方法和其他简单的java 这些方法非常有用。

int length = inputWord.length();
int last = length-1;
String lastLetter = inputWord.substring(last);

并非非常困难,但你可能认为它过于复杂。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签