zoukankan      html  css  js  c++  java
  • 课堂随笔

    1.

    实验代码:

    import java.util.Scanner;
    public class Test2 {
    public static void main(String[] args){
    String s;
    Scanner scan = new Scanner(System.in);
    System.out.print("请输入一段字符串:");
    s = scan.next();
    String st = new String();
    char m ;
    for(int i = 0;i < s.length();i ++)
    {
    m=s.charAt(i);
    if(((m != 'x')&&(m != 'y')&&(m != 'z'))&&((m != 'X')&&(m != 'Y')&&(m != 'Z')))
    {
    m=(char)(m + 3);
    }
    else
    {
    m = (char)(m - 23);
    }
    st=st + m;
    }
    System.out.println("加密后的字符串为:"+st);
    }
    }、

    实验截图:

                                                                   

    实验流程图:

                                                                                                   输入字符串

                                                                                                          |

                                                                                         将字符串遍历并且转化为char类型

                                                                                                          |

                                                                                              判断字符是否为x,y,z

                                                                                             |                             |

                                                                                 不是,则m = m + 3      是,则m = m - 21

    2.

    public int length()
    返回字符串的长度;

    public char charAt(int index)
    返回字符串中第index个字符;

    public String toUpperCase()
    返回一个字符串为该字符串的大写形式

    public String toLowerCase()
    返回一个字符串为该字符串的小写形式

    public String trim()
    返回该字符串去掉开头和结尾空格后的字符串

    public String replace(char oldchar,char newChar)
    在字符串中用newChar字符替换oldChar字符

  • 相关阅读:
    Hadoop集群(三) Hbase搭建
    Hadoop集群(二) HDFS搭建
    Hadoop集群(一) Zookeeper搭建
    Redis Cluster 添加/删除 完整折腾步骤
    Redis Cluster在线迁移
    Hadoop分布式HA的安装部署
    Describe the difference between repeater, bridge and router.
    what is the “handover” and "soft handover" in mobile communication system?
    The main roles of LTE eNodeB.
    The architecture of LTE network.
  • 原文地址:https://www.cnblogs.com/overs/p/6005069.html
Copyright © 2011-2022 走看看