回文字符串有两种:abcba,abccba。

代码:

     static boolean func(String str) {
int len = str.length();
for (int i = 0; i < len / 2; i++) {
if(str.charAt(i)!=str.charAt(len-1-i))
return false;
}
return true;
}

我喜欢在遍历的时候只用一个索引i,另一个索引就用len-i-1表示。

Java 判断是否为回文字符串的更多相关文章

  1. Java判断是否是回文字符串

    public static boolean isPalindrome(String str) { int start = 0, end = str.length() - 1; while (start ...

  2. 判断回文字符串(c,python)

    回文字符串:一个字符串,不论是从左往右,还是从右往左,字符的顺序都是一样的(如abba,abcba等) 判断回文字符串比较简单,即用两个变量left,right模仿指针(一个指向第一个字符,一个指向最 ...

  3. leetcode:Longest Palindromic Substring(求最大的回文字符串)

    Question:Given a string S, find the longest palindromic substring in S. You may assume that the maxi ...

  4. leetcode 5 Longest Palindromic Substring--最长回文字符串

    问题描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum ...

  5. 131. 132. Palindrome Partitioning *HARD* -- 分割回文字符串

    131. Palindrome Partitioning Given a string s, partition s such that every substring of the partitio ...

  6. Longest Palindromic Substring (最长回文字符串)——两种方法还没看,仍需认真看看

    Given a string S, find the longest palindromic substring in S. You may assume that the maximum lengt ...

  7. Java 判断回文字符串有多少和其中的最大字符串

    一.简介代码功能 该代码的功能可以实现对任意的一段字符串进行判断是否有回文,回文有哪些,和其中的最大回文. 二.代码部分 1.全局变量 static String hws = "" ...

  8. C,C++回文字符串判断(字符串指针的用法)

    功能:输入一个字符串,判断是否为回文. 主要锻炼指针的用法. 1.C版 #include<stdio.h> int main() { ]; char a; ,flag=; while((a ...

  9. 判断回文字符串、回文链表、回文数(python实现)

    所谓回文字符串,就是正读和反读都一样的字符串,比如"level"或者"noon"等等就是回文串.即是对称结构 判断回文字符串 方法一: def is_palin ...

随机推荐

  1. leetcode-easy-listnode-237 Delete Node in a Linked List

    mycode # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # sel ...

  2. poi生成excel整理(设置边框/字体/颜色/加粗/居中/)

    转: poi生成excel整理(设置边框/字体/颜色/加粗/居中/) 2016年12月02日 11:05:23 吃奶的牛 阅读数:34324   HSSFWorkbook wb = new HSSFW ...

  3. 阶段3 2.Spring_04.Spring的常用注解_3 用于创建的Component注解

    @Component spring容器是一个Map结构,是由于key 和vlaue组成的 运行测试 无法运行 出错的原因↓ 第一部是解析配置文件.但是配置文件这里是空的.我们的bean里面什么对象都没 ...

  4. Linux 常用命令之 mv cp scp

    1.mv 命令是move的缩写,用于文件(或文件夹)移动的. 1)将 luna 目录下的文件 a.txt,移动到 miracle 目录下: mv ./luna/a.txt ./miracle/ 2)将 ...

  5. ATP检测 BAPI BAPI_MATERIAL_AVAILABILITY

    *****ATP检测        DATA: END_RLT LIKE EBAN-LFDAT,              NOT_AVAILABLE,              AVAILABLE( ...

  6. MySQL 常见面试知识点

    之前简单总结了一下MySQL的场景面试知识点 1.讲下MVCC原理 2.MySQL高可用架构介绍 3.OSC(在线更改表结构)原理 4.MySQL性能调优有哪些关键点/经验 5.MySQL在线备份方案 ...

  7. Install the Flash plug-in

    Flash is a plug-in for your web browser that allows you to watch videos and use interactive web page ...

  8. asp.net mvc model attribute and razor and form and jquery validate 完美结合

    1.创建Model,添加标注. [Serializable] public class BaseUserModel:BaseModel { [StringLength(100)] [Required( ...

  9. java:JavaScript2:(setTimeout定时器,history.go()前进/后退,navigator.userAgent判断浏览器,location.href,五种方法获取标签属性,setAttribute,innerHTML,三种方法获取form表单信息,JS表单验证,DOM对象,form表单操作)

    1.open,setTimeout,setInterval,clearInterval,clearTimeout <!DOCTYPE> <html> <head> ...

  10. 使用FreeHttp任意篡改http报文 (FreeHttp使用及实现说明)

    本文转自:https://www.cnblogs.com/lulianqi/p/10428551.html 前言 FreeHttp是一个Fiddler插件借助FreeHttp您可按照您自己的设定修改请 ...