String index out of range: -4 错误解析
报这个错误是由于对字符串进行操作的过程中抛出了StringIndexOutOfBoundsException异常
下面的几种方法均有可能抛出上述异常:
String.substring()
String.charAt()
String.codePointAt()
String.codePointBefore()
String.subSequence()
String.getChars()
String.getBytes()
原因分析:
这个错误的意思是字符串的索引越界了
一般都是在对字符串进行操作的时候引起的,例如
String str = "123"; //字符串的长度是3
str.substring(0,str.length()-4); //会报错String index out of range: -4
String index out of range: -4 错误解析相关推荐
- java.lang.StringIndexOutOfBoundsException: String index out of range: 0错误的原因
2019独角兽企业重金招聘Python工程师标准>>> java.lang.StringIndexOutOfBoundsException: String index out of ...
- Excel 导入数据库中java.lang.StringIndexOutOfBoundsException: String index out of range: -50提示解决原因...
dbf文件另存为.xls然后导入到sql数据库里会报错. java.lang.StringIndexOutOfBoundsException: String index out of range: - ...
- java.lang.StringIndexOutOfBoundsException: String index out of range: -1
在这里插入代码片 package com.itheima.d3_char_buffer; import java.io.*; import java.util.ArrayList; import ja ...
- 踩坑,String index out of range: -1,MultipartFile中getOriginalFilename()和getName方法
我是方圆,这些天博客更的少,是因为在慢吞吞的敲项目和写作业 最终导致String index out of range: -1问题的是String.substring(),字符串越界嘛,因为我要截取图 ...
- 索引越位:String index out of range: 1
一.String index out of range: 1 出现这种问题的原因,是因为字符串的索引越位. 报错内容: 报错位置: 报错原因:因为我循环使用的是字母"j",但是我写 ...
- IndexError: list index out of range的错误原因及解决方案
本人在读取txt文件时遇到IndexError: list index out of range 如下图: 于是检查错误原因,加入如下代码: 以指导rows一共有20662行,往下翻结果,还是报错了: ...
- string’ does not name a type 错误解析
'string' does not name a type 今天写代码有一次遇见这错误!虽然不是第一次遇见了,但还是耽误了一小会,为了不再耽误时间,所以把错误写下 示例理解: #ifndef EM ...
- String index out of range: -824264796 不明的原因导致驱动程序造成失败,请回报这个例外。
报错 2018-08-27 11:26:57.307 ERROR 7188 --- [eate-1016098114] com.alibaba.druid.pool.DruidDataSource : ...
- java.lang.StringIndexOutOfBoundsException: String index out of range: 1
笔者源码如下: package javaPractice;import java.util.*;public class TestScanner {public static void main(St ...
最新文章
- matlab极大值点个数,求一组数的极大值个数
- 深度学习参数怎么调优,这12个trick告诉你
- 达梦数据库修改字段长度_DM7 达梦数据库 序列 和 自增列 说明
- android控件拖动,移动、解决父布局重绘时控件回到原点
- Java中Math3 各种随机数生成器的使用(Random Generator)
- 去除div css背景,jQuery-拖动div CSS背景
- tushare 安装
- 炼丹手册——NaN值问题
- 告别Demo项目,参与真实AI企业项目
- IPC网络高清摄像机基础知识1(IPC芯片市场分析以及“搅局者”华为海思 “来自2013年”)
- 用计算机画图教案,电脑绘画美术教案设计
- 易语言开发的cnzz站长统计留痕软件,成品原理源码分享
- ubuntu 安装截图工具 Shutter,并设置快捷键 Ctrl+SuperL
- 深度学习之图像分类(九)--ResNeXt 网络结构
- C++课程设计(校车订票管理系统)
- HTML 请输入关键字的搜索框,功能:输入时:框内的请输入关键字消失,鼠标移开时 框内的请输入关键字又重现
- 小云计算机,小云路由器 web服务器
- python应用——将raw文件转化为jpg文件,并显示图像
- 大数据因果推理与学习入门综合概述
- Excel快速将多个单元格合并到一个单元格