• 判断字符串的开头和结尾


    package com.text_1;
    
    public class lianxi1111 {
    
    	public static void main(String[] args) {
    		// TODO 自动生成的方法存根
    		//代码实现判断字符串的开头和结尾
    		String str="jnjcubhksbwiowhfkalohafwac";
    		 
    		if (str.indexOf("jnj")==0)
    		{
    			System.out.println("jnj"+"是字符串的开头");
    		}
    		else
    		{
    			System.out.println("cuowu");
    		}
    	    //System.out.println(str.length());
    	    
    		//System.out.println(str.substring(str.length()-3));
    		String str2 = "wac";
    		if(str.substring(str.length()-3).equals(str2))
    		{
    			System.out.println("字符串的结尾是"+"wac");
    		}
    		else
    		{
    			System.out.println("cuowu");
    		}
    
    	}
    
    }
    

  • 相关阅读:
    swift
    swift
    ios
    Swift
    swift
    swift
    /var/log/cron
    Django 数据传递
    HTML 属性
    HTML 元素
  • 原文地址:https://www.cnblogs.com/jakeasd/p/5491635.html
Copyright © 2020-2023  润新知