# 阿里面试题
# LeakCanary 实现原理
LeakCanary核心原理源码浅析 (opens new window)
# 内存泄露的本质
无法回收无用的对象
# Handler 队列阻塞算法、在Android中的地位、如何自己实现?
Android应用程序消息处理机制(Looper、Handler)分析 (opens new window)
# C 和 java 如何通信?JNI原理
Java JNI实现原理初探 (opens new window)
# 比较熟悉的开源项目源码分析
okhttp、glide
# 线程池定制、源码分析
# 虚拟机如何实现的synchronized?
Java SE1.6中的Synchronized (opens new window)
# 一个文件中有100万个整数,由空格分开,在程序中判断用户输入的整数是否在此文件中。说出最优的方法
# 两个进程同时要求写或者读,能不能实现?如何防止进程的同步?
# volatile 的意义?
防止CPU指令重排序
# 单例
public class Singleton{
private volatile static Singleton mSingleton;
private Singleton(){
}
public static Singleton getInstance(){
if(mSingleton == null){\\A
synchronized(Singleton.class){\\C
if(mSingleton == null)
mSingleton = new Singleton();\\B
}
}
return mSingleton;
}
}
# Given a string, determine if it is a palindrome(回文,如果不清楚,按字面意思脑补下), considering only alphanumeric characters and ignoring cases.
For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome.
Note: Have you consider that the string might be empty? This is a good question to ask during an interview. For the purpose of this problem, we define empty string as valid palindrome.
public boolean isPalindrome(String palindrome){
char[] palindromes = palidrome.toCharArray();
if(palindromes.lengh == 0){
return true
}
Arraylist<Char> temp = new Arraylist();
for(int i=0;i<palindromes.length;i++){
if((palindromes[i]>'a' && palindromes[i]<'z')||palindromes[i]>'A' && palindromes[i]<'Z')){
temp.add(palindromes[i].toLowerCase());
}
}
for(int i=0;i<temp.size()/2;i++){
if(temp.get(i) != temp.get(temp.size()-i)){
//
return false;
}
}
return true;
}
# 烧一根不均匀的绳,从头烧到尾总共需要1个小时。现在有若干条材质相同的绳子,问如何用烧绳的方法来计时一个小时十五分钟呢
用两根绳子,一个绳子两头烧,一个一头烧。一根烧完后,把另外一根也两头烧。所以是30+45 共75分钟。
← 腾讯