hyb1996
码龄10年
求更新 关注
提问 私信
  • 博客:6,252
    问答:47,760
    54,012
    总访问量
  • 14
    原创
  • 28
    粉丝
  • 1
    关注
IP属地以运营商信息为准,境内显示到省(区、市),境外显示到国家(地区)
IP 属地:重庆市
加入CSDN时间: 2015-09-15

个人简介:呵呵哒

博客简介:

hyb1996的博客

查看详细资料
个人成就
  • 获得2次点赞
  • 内容获得3次评论
  • 获得1次收藏
  • 博客总排名1,717,416名
创作历程
  • 13篇
    2018年
  • 1篇
    2016年
TA的专栏
  • 现代操作系统应用开发

TA关注的专栏 0

TA关注的收藏夹 0

TA关注的社区 11

TA参与的活动 0

创作活动更多

王者杯·14天创作挑战营·第2期

这是一个以写作博客为目的的创作活动,旨在鼓励码龄大于4年的博主们挖掘自己的创作潜能,展现自己的写作才华。如果你是一位热爱写作的、想要展现自己创作才华的小伙伴,那么,快来参加吧!我们一起发掘写作的魅力,书写出属于我们的故事。 注: 1、参赛者可以进入活动群进行交流、分享创作心得,互相鼓励与支持(开卷),答疑及活动群请见https://bbs.csdn.net/topics/619735097 2、文章质量分查询:https://www.csdn.net/qc 我们诚挚邀请你们参加为期14天的创作挑战赛!

58人参与 去参加
  • 最近
  • 文章
  • 专栏
  • 代码仓
  • 资源
  • 收藏
  • 关注/订阅/互动
更多
  • 最近

  • 文章

  • 专栏

  • 代码仓

  • 资源

  • 收藏

  • 关注/订阅/互动

  • 社区

  • 帖子

  • 问答

  • 课程

  • 视频

搜索 取消

152. Maximum Product Subarray (受CSDN限制,本文为22号发表,但实际上是1月早写好的)

题目Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the
原创
发布博客 2018.01.22 ·
446 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

239. Sliding Window Maximum (受CSDN限制,本文为22号发表,但实际上是1月早写好的)

题目Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sl
原创
发布博客 2018.01.22 ·
291 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

121. Best Time to Buy and Sell Stock (受CSDN限制,本文为22号发表,但实际上是1月早写好的)

题目Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the
原创
发布博客 2018.01.22 ·
348 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

457. Circular Array Loop

题目You are given an array of positive and negative integers. If a number n at an index is positive, then move forward n steps. Conversely, if it's negative (-n), move backward n steps. Assume the
原创
发布博客 2018.01.13 ·
326 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

493. Reverse Pairs

题目Given an array nums, we call (i, j) an important reverse pair if i  and nums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array.Example1:Input
原创
发布博客 2018.01.13 ·
276 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

315. Count of Smaller Numbers After Self

题目You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].
原创
发布博客 2018.01.13 ·
202 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

215. Kth Largest Element in an Array

题目Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, retu
原创
发布博客 2018.01.13 ·
209 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

130. Surrounded Regions

题目Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For exam
原创
发布博客 2018.01.13 ·
184 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

120. Triangle

题目Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,
原创
发布博客 2018.01.13 ·
264 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

150. Evaluate Reverse Polish Notation

题目Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2
原创
发布博客 2018.01.13 ·
183 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

4. Median of Two Sorted Arrays

题目There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. Example 1:nums1 = [1, 3]nums2 = [2]The median is 2.0Example 2
原创
发布博客 2018.01.13 ·
203 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

338. Counting Bits

题目Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For
原创
发布博客 2018.01.13 ·
262 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

62. Unique Paths

题目A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to re
原创
发布博客 2018.01.13 ·
254 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

星尘计算器开发日志

我是初三的时候开始接触编程的。第一次接触的语言是Mobile Basic 高一的时候开始接触Java ME的编程,便产生了写一个计算器的想法,主要是因为自己对计算器的兴趣、热情和了解,同时在当时的Java ME平台上没有好用的计算器。当时每周回家只有几个小时的电脑时间,甚至有时只能用手机写代码,在学校的时候经常拿出本子手写代码,作为一种放松方式。这是一个缓慢艰难但有趣的过程,并且我也享受其中。于是...
原创
发布博客 2016.05.29 ·
2619 阅读 ·
2 点赞 ·
2 评论 ·
0 收藏

android button字体大小根据宽度动态适配

答:

问题解决了。明天再把代码发上来。

回答问题 2016.05.10

android button字体大小根据宽度动态适配

发布问题 2016.05.10 ·
6 回答

一道非常基础的java问题

答:

http://m.blog.csdn.net/article/details?id=8104505

  Java是一种动态连接的语言,常量池的作用非常重要,常量池中除了包含代码中所定义的各种基本类型(如int、long等等)和对象型(如String及数组)的常量值还,还包含一些以文本形式出现的符号引用,比如:

  类和接口的全限定名;

  字段的名称和描述符;

  方法和名称和描述符。

  在C语言中,如果一个程序要调用其它库中的函数,在连接时,该函数在库中的位置(即相对于库文件开头的偏移量)会被写在程序中,在运行时,直接去这个地址调用函数;

  而在Java语言中不是这样,一切都是动态的。编译时,如果发现对其它类方法的调用或者对其它类字段的引用的话,记录进class文件中的,只能是一个文本形式的符号引用,在连接过程中,虚拟机根据这个文本信息去查找对应的方法或字段。

  所以,与Java语言中的所谓“常量”不同,class文件中的“常量”内容很非富,这些常量集中在class中的一个区域存放,一个紧接着一个,这里就称为“常量池”。

java中的常量池技术,是为了方便快捷地创建某些对象而出现的,当需要一个对象时,就可以从池中取一个出来(如果池中没有则创建一个),则在需要重复重复创建相等变量时节省了很多时间。常量池其实也就是一个内存空间,不同于使用new关键字创建的对象所在的堆空间。本文只从java使用者的角度来探讨java常量池技术,并不涉及常量池的原理及实现方法。个人认为,如果是真的专注java,就必须对这些细节方面有一定的了解。但知道它的原理和具体的实现方法则不是必须的。

常量池中对象和堆中的对象
public class Test{

Integer i1=new Integer(1);
Integer i2=new Integer(1);
//i1,i2分别位于堆中不同的内存空间

System.out.println(i1==i2);//输出false

Integer i3=1;
Integer i4=1;
//i3,i4指向常量池中同一个内存空间

System.out.println(i3==i4);//输出true

//很显然,i1,i3位于不同的内存空间

System.out.println(i1==i3);//输出false

}
8种基本类型的包装类和对象池
java中基本类型的包装类的大部分都实现了常量池技术,这些类是Byte,Short,Integer,Long,Character,Boolean,另外两种浮点数类型的包装类则没有实现。另外Byte,Short,Integer,Long,Character这5种整型的包装类也只是在对应值小于等于127时才可使用对象池,也即对象不负责创建和管理大于127的这些类的对象。以下是一些对应的测试代码:

public class Test{

public static void main(String[] args){

//5种整形的包装类Byte,Short,Integer,Long,Character的对象,

//在值小于127时可以使用常量池

Integer i1=127;

Integer i2=127;

System.out.println(i1==i2)//输出true

//值大于127时,不会从常量池中取对象

Integer i3=128;

Integer i4=128;

System.out.println(i3==i4)//输出false

//Boolean类也实现了常量池技术

Boolean bool1=true;

Boolean bool2=true;

System.out.println(bool1==bool2);//输出true

//浮点类型的包装类没有实现常量池技术

Double d1=1.0;

Double d2=1.0;

System.out.println(d1==d2)//输出false

}

}
String也实现了常量池技术
String类也是java中用得多的类,同样为了创建String对象的方便,也实现了常量池的技术,测试代码如下:

public class Test{

public static void main(String[] args){

//s1,s2分别位于堆中不同空间

String s1=new String("hello");

String s2=new String("hello");

System.out.println(s1==s2)//输出false

//s3,s4位于池中同一空间

String s3="hello";

String s4="hello";

System.out.println(s3==s4);//输出true

}

}
最后
细节决定成败,写代码更是如此。

在JDK5.0之前是不允许直接将基本数据类型的数据直接赋值给其对应地包装类的,如:Integer i = 5;

但是在JDK5.0中支持这种写法,因为编译器会自动将上面的代码转换成如下代码:Integer i=Integer.valueOf(5);

这就是Java的装箱.JDK5.0也提供了自动拆箱. Integer i =5; int j = i;

Integer的封装:

public static Integer valueOf(int i) {

final int offset = 128;

if (i >= -128 && i <= 127) { // must cache

return IntegerCache.cache[i + offset];

}

return new Integer(i);

}

private static class IntegerCache {

private IntegerCache(){}

static final Integer cache[] = new Integer[-(-128) + 127 + 1];

static {

for(int i = 0; i < cache.length; i++)

cache[i] = new Integer(i - 128);

}

}

由于cache[]在IntegerCache类中是静态数组,也就是只需要初始化一次,即static{......}部分,所以,如果Integer对象初始化时是-128~127的范围,就不需要再重新定义申请空间,都是同一个对象---在IntegerCache.cache中,这样可以在一定程度上提高效率。

回答问题 2016.03.08

android 画一对漂亮的括号

答:

问题解决了。采用一张比较大的PNG括号图片,根据需要进行放缩节OK。


private static final int textBracketMaxHeight = ViewTools.dip2px(20);
    private static final int textBracketMaxWidth = ViewTools.dip2px(10);

 public static void drawLeftBracketPng(Canvas canvas, int x, int y,
            int height){
        Bitmap btp;
        if (height > textBracketMaxHeight) {
            btp = ViewTools.zoom(leftBracketPng, textBracketMaxWidth, height);
        }else{
            float scale = (float)height/leftBracketPng.getHeight();
            btp = ViewTools.zoom(leftBracketPng, scale, scale);
        }
        canvas.drawBitmap(btp, x, y, new Paint());
    }
    public static void drawRightBracketPng(Canvas canvas, int x, int y,
            int height){
        Bitmap btp;
        if (height > textBracketMaxHeight) {
            btp = ViewTools.zoom(rightBracketPng, textBracketMaxWidth, height);
        }else{
            float scale = (float)height/rightBracketPng.getHeight();
            btp = ViewTools.zoom(rightBracketPng, scale, scale);
        }
        canvas.drawBitmap(btp, x, y, new Paint());
    }
回答问题 2016.03.04

android 画一对漂亮的括号

发布问题 2016.02.28 ·
4 回答

JAVA多线程如何理解这句话?

答:

实际测试,是可以调用其他加锁函数的。只能说是如果有两个该线程实例则无法同时运行。因此我认为这句话是错的。

回答问题 2016.02.24
加载更多