public class JPTQuestion2 {
    public static void main(String[] args) {
        String s3 = "JournalDev";
        int start = 1;
        char end = 5;
        System.out.println(start + end);
        System.out.println(s3.substring(start, end));
    }
}

注意:这里的end是char类型,可是,输出结果和int型的end没区别。

原因:...........

官方解释:

Java Programming Test Question 2 Answer and Explanation

The given statements output will be ourn. First character will be automatically type caste to int. After that since in java first character index is 0, so it will start from o and print till n. Note that in String substring function it leaves the end index.

Java Programming Test Question 2的更多相关文章

  1. Java Programming Test Question 3

    import java.util.HashSet; public class JPTQuestion3 { public static void main(String[] args) { HashS ...

  2. Java Programming Test Question 1

    public class JPTQuestion1 { public static void main(String[] args) { String s1 = "abc"; St ...

  3. Java Programming Test Question 4

    What will be the boolean flag value to reach the finally block? public class JPTQuestion4 { public s ...

  4. Java programming language compiler

    https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html\ javac - Java programming l ...

  5. Java Programming Language Enhancements

    引用:Java Programming Language Enhancements Java Programming Language Enhancements Enhancements in Jav ...

  6. 文本信息“welcome to java programming!”

    import javax.swing.JOptionPanepublic class welcome {public static void main(string[] arg){JOptionPan ...

  7. C Programming vs. Java Programming

    Thing C Java type of language function oriented object oriented basic programming unit function clas ...

  8. Difference Between Arraylist And Vector : Core Java Interview Collection Question

    Difference between Vector and Arraylist is the most common  Core Java Interview question you will co ...

  9. Java Programming Guidelines

    This appendix contains suggestions to help guide you in performing low-level program design and in w ...

随机推荐

  1. springMVC数据验证出现404错误解决办法

    今天使用springMVC的数据验证的时候,看似很简单的东西,却有一个很大的陷阱:提交空表单的时候总是出现404错误,但是后台却不给你报任何错.遇到这个错误这个很苦恼,搞了几小时,今天记录并分享一下解 ...

  2. 【Codeforces-707D】Persistent Bookcase DFS + 线段树

    D. Persistent Bookcase Recently in school Alina has learned what are the persistent data structures: ...

  3. ubuntu安装mysql--参考的网址

    Ubuntu服务器常用配置-mysql数据库的安装 - SegmentFault MySQL 社区-你身边最优秀的MySQL中文社区! MySQL咨询,MySQL培训,MySQL优化 - Powere ...

  4. 【poj3141】 Distant Galaxy

    http://poj.org/problem?id=3141 (题目链接) 题意 给出平面上n个点,找出一个矩形,使边界上包含尽量多的点. solution 不难发现,除非所有输入点都在同一行或同一列 ...

  5. .net读写config appsetting

    读 this.txtOutPutPath.Text = ConfigurationManager.AppSettings["OutPutPath"]; this.txtFilter ...

  6. eclipse crash

    SIGSEGV (0xb) at pc=0x00007fbcae8f2c91, pid=5707, tid=140449979574016 JRE version: 7.0_25-b30 Java V ...

  7. iOS&Node 搭建WebSocketServer实现聊天

    Server端使用的是Node.JS里的一个Socket.io的模块 iOS客户端使用的是SocketIO和SBJson框架 作者的源码有些问题,我做了一些自定义的修改. 代码地址:https://g ...

  8. Python3 学习笔记------迭代器

    python 迭代器 要理解python迭代器(iterator),先要理解两个概念:Iterable(可迭代对象).Iterator(迭代器) 先来help()一下Iterator: >> ...

  9. JQuery 技巧积累与总结

    1.获得select 元素选中的值 $('#WishlistSelect option:selected').val(); 2.设置按钮的disabled属性的实现代码 $('#button').at ...

  10. 深入理解JavaScript中创建对象模式的演变(原型)

    深入理解JavaScript中创建对象模式的演变(原型) 创建对象的模式多种多样,但是各种模式又有怎样的利弊呢?有没有一种最为完美的模式呢?下面我将就以下几个方面来分析创建对象的几种模式: Objec ...