小编Tru*_*yen的帖子

如何完成反向字符串?

因此,我的老师告诉我要制作一个字符串,使我输入的任何东西按相反的顺序排列(例如"你好那里"变成"ereht olleh").到目前为止,我在身体上工作,我想出了这个

   public class Main {

/**
 * @param args the command line arguments
 */     

  public static void main(String[] args) {
  (The input needs to be in here)}}



    public static String rev(String str) {

    String reversed = "hello there";
    for (int i = 0; i < str.length(); i++) {
        reversed = str.charAt(i) + reversed;
    }
    return reversed;
Run Code Online (Sandbox Code Playgroud)

我现在的问题是我需要在public static void main(String [] args)下放置它才能使它工作.是的,我明白这是家庭作业,我试着通过这本书寻求帮助(没有运气).我试着在互联网上寻找(没有运气,这要归功于我对更先进的方法的了解不多).我将不胜感激任何帮助,并提前感谢任何人.我使用netbeans,如果这会有所帮助.

java string reverse

2
推荐指数
1
解决办法
2396
查看次数

完成垂直字符串

所以这就是我到目前为止我的垂直字符串.

public static void main(String[] args) {
    (**What do I put in here?**)
}

public static void vertical(String str) {
    String vertical = "hey now";
    for (int i = 0; i < str.length(); i++) {
        System.out.println(str.charAt(i));
    }
}   
Run Code Online (Sandbox Code Playgroud)

我的老师查看了我的字符串中的"大纲"部分.我在这里的问题是我放下什么public static void main(String[] args)(注意括号)并让它产生:

h
e
y

n
o
w

我觉得我需要把它放在System.out.println那里,但我只是不确定.任何有关制作上述内容的帮助将不胜感激.非常感谢你.

是的,使用垂直(字符串str)我想嘿现在垂直向下.如果我只是通过使用/ n得到等级我会TT.

java netbeans

0
推荐指数
1
解决办法
1439
查看次数

标签 统计

java ×2

netbeans ×1

reverse ×1

string ×1