由买买提看人间百态

topics

全部话题 - 话题: boolean
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
S*******C
发帖数: 822
1
a+b不match b,但很多test case通不过,看看怎么回事
public class Solution {
public boolean match(String s, String p) {
return match(s, 0, p, 0);
}
private boolean match(String s, int i, String p, int j) {
if (j >= p.length() - 1) {
return i >= s.length() - 1;
} else if (i >= s.length() - 1) {
return j >= p.length() - 1;
}
if (p.charAt(j + 1) == '*') {
// match(s+1, p) - match next char in s.
// match(s, p+2) - mat... 阅读全帖
p*****2
发帖数: 21240
2

缺省的实现貌似是一样的呀
default boolean removeIf(Predicate filter) {
Objects.requireNonNull(filter);
boolean removed = false;
final Iterator each = iterator();
while (each.hasNext()) {
if (filter.test(each.next())) {
each.remove();
removed = true;
}
}
return removed;
}
J*****v
发帖数: 314
3
public boolean checkInfluencer(boolean[][] followingMatrix) {
if (followingMatrix == null || followingMatrix.length == 0 ||
followingMatrix[0].length == 0)
return false;
int len = followingMatrix.length;
int res = 0;
for (int i = 1; i < len; ++i) {
if (!followingMatrix[i][res] || followingMatrix[res][i]) {
res = i;
}
}
// verify it is indeed an influencer
for (int i = 0; i < len; i++) {
... 阅读全帖

发帖数: 1
4
来自主题: JobHunting版 - 打车公司一题求解
二维比较难想,可以先想想一维的情况。这题也可能和二分图有关。我下班后试试。
我擦,匈牙利算法早忘光光了,只记得dfs, 囧。。。
class Location {
Location(int x, int y) {
this.x = x;
this.y = y;
}
public int hashCode() {
return x | y;
}
public boolean equals(Object obj) {
if (obj == null) return false;
else {
if (obj instanceof Location) {
Location l = (Location)obj;
return l.x == x && l.y == y;
} else {
return false;
... 阅读全帖

发帖数: 1
5
来自主题: JobHunting版 - 脸家电话面试面筋
第一题我也不太会,在网上搜的一个答案, 不知道大牛具体是怎么做的。
public boolean isIncreasingOrDecreasing(int[] arr) {
boolean increasing = true, decreasing = true;
if (arr.length <= 2) {
return true;
}
for (int i = 1; i < arr.length; i++) {
if (arr[i] < arr[i-1]) {
increasing = false;
}
if (arr[i] > arr[i-1]) {
decreasing = false;
}
if (!increasing && !decreasing) {
return false;
}
}
return true;
}

发帖数: 1
6
public class Solution {
public List removeInvalidParentheses(String s) {
List res = new ArrayList<>();
Queue queue = new LinkedList<>();
Set checked = new HashSet<>();
boolean found = false;
int max = 0;
queue.add(s);
while (!queue.isEmpty()) {
String t = queue.remove();
if (isValid(t)) {
found = true;
if (t.length() >= max && !res.contains(t)) {
... 阅读全帖
B*****n
发帖数: 654
7
来自主题: JobMarket版 - 有没有Exxon的,求内推 (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: Boolean (Soso), 信区: JobHunting
标 题: 有没有Exxon的,求内推 (转载)
发信站: BBS 未名空间站 (Wed Sep 11 16:55:56 2013, 美东)
发信人: Boolean (Soso), 信区: Macromolecules
标 题: 有没有Exxon的,求内推
发信站: BBS 未名空间站 (Wed Sep 11 16:54:33 2013, 美东)
Texas A&M 博后找工作中, 看了exxon mobile的职位觉得很match, 求推荐
g****s
发帖数: 1755
8
来自主题: JobMarket版 - 请教面试JAVA考题最佳算法
抱歉,是我理解错了;
如果整个数列可以随意arrange的话,需要O(n^2);
即需要要计算任意组合的sum值。需要用到Combination的算法。
import java.util.HashSet;
import java.util.Scanner;
public class PartitionProblem {
public static void main(String[] args){
//int[] array = creatArray();
int[] array = {1,2,2,3,5,7};
boolean PN = partitionPro(array);
if(PN) System.out.println("yes!");
else System.out.println("Nope.");
}//end main()
private static boolean partitionPro(int[] array) {
// TODO Auto-generated method stub
int totalSum = 0;
HashSet su... 阅读全帖
g*****y
发帖数: 349
9
第一次买Tiger Direct的东西做Total defense的rebate,现在想去把自动续订关掉,
可是网站(https://my.totaldefense.com/Login2.aspx)根本登陆不进去啊,无论用
哪个电脑,什么浏览器,总是出现这个信息:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an i... 阅读全帖
t******l
发帖数: 10908
10
来自主题: Parenting版 - 做数学题了,不知道是几年级的
google search “boolean satisfiability problem for dummies”。。。
当然图灵说了,还需要一个 I/O 转换头把 Math Proof Problem 转化为 boolean
satisfiability problem 就是了。。。I/O 转换头不是个难事就是了,4 pin 到
6 pin。。。比如 sample 转换头:“if 拉面 is true,then 金巴赫 is true.
Otherwise not.”
t******l
发帖数: 10908
11
来自主题: Parenting版 - 数学家出的智力题
或者从马工的 SAT problem ( Boolean Satisfiable Problem ) 的角度,你如果把
logistician 定义为 Boolean Expression,也就是不能存 state 的那种,那你就无法
counting days。。。你给 3SAT solver 输入一个 counter 进去?我不知道咋输入的
说。。。
当然,如果你允许输入 counter 的话,那罗素说了,我送一个阿发狗进去,跟
counter 有本质差别么?
当然我觉得这道题本质上是 pre-formal-logics 的脑筋急转弯题,经不起深究就是了。

:老掉牙的题了,推理很简单。不过为啥游客说的不是废话呢。简单一点,假设只有三
个蓝眼睛。
:命题一,每个人都知道存在蓝眼睛
t******l
发帖数: 10908
12
来自主题: Parenting版 - 数学家出的智力题
想了想,这个 logistician 应该是 simple binary logic function w/o states,
cannot store (出题人不喜欢的) constants, but allow counter 。。。
总之我觉得这就是 recreational math 脑筋急转弯,不能从 post-formal-logics
thinking 的角度深究就是了 。。

:或者从马工的 SAT problem ( Boolean Satisfiable Problem ) 的角度,你如果把
:logistician 定义为 Boolean Expression,也就是不能存 state 的那种,那你就无
法 counting days。。。你给 3SAT solver 输入一个 counter 进去?我不知道咋输入
的说。。。
T**********y
发帖数: 157
13
来自主题: Returnee版 - 快来看牛逼的27岁教授
【 以下文字转载自 Faculty 讨论区 】
发信人: TenMilesADay (郭十迈), 信区: Faculty
标 题: 快来看牛逼的27岁教授
发信站: BBS 未名空间站 (Sun Mar 11 13:14:59 2012, 美东)
http://www.ccse.uestc.edu.cn/teacher/teacher.aspx?id=414
所有已经发表论文清单
(发表时间序)

【1】 周涛,傅忠谦,周佩玲,张建荣,张德学,”基于遗传算法的大规模流量
工程问题求解”,计算机应用,2003年第6期,43-45
【2】 杨春霞,周涛,周佩玲,刘隽,基于Multi_Agent的股市经济系统建模与
分析,自动化理论、技术与应用卷十,中国科学技术大学出版社,2003年,596-601(
中国自动化学会第18届青年学术年会会议论文集)
【3】 周佩玲,许民,赵亮,周涛,”混沌信号奇异性检测与外界冲击度量”,
数据采集与处理,Vol.19,195-198,2004
【4】 周涛,徐俊明,刘隽,”图直径和平均距离极值问题研究”,... 阅读全帖
c***d
发帖数: 26
14
都5天了,今天还不行啊。
是不是这个错误?
Server Error in '/QotW' Application.
Invalid operation. The connection is closed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Invalid operation. The
connection is closed.
Source Error:
Line 806: cmd.Parameters.Add(new OracleParameter("SESSIONID",
sessionID... 阅读全帖
w*****g
发帖数: 186
15
来自主题: Stock版 - IB的程序交易API,怎么样?
能多指导一下吗? 我用==只是个例子,我想知道的是:
(1)方不方便得到dow的实时数据?
比如“dow>=71000",这样的条件在IB容易programing吗?
(2)在IB里面容易定义boolean varialbe吗?
比如:Boolean toBuy
if(toBuy)
buy GE 100
(3)容易得到time variable吗?
比如说我要在股市关门之前close my position
比如:if (currentTime >= 3:50pm)
sell my position
l***y
发帖数: 1166
16
国籍法有bug, 也许会出现死循环。并且外国国籍法可能优先中国国籍法。
另外,两个中国人的小孩的国籍可能由外国国籍法决定;
一个中国人和一个外国人的小孩有可能仅由中国国籍法决定。
看来国籍法的制定真是一门技术活。虽然国籍法的本意是中国人和外国人的小孩要拉拢
到中国的怀抱,但是wang外国靠的中国人的小孩要排除在中国之外,但是具体实施就有
bug了。
国籍法第五条:父母双方或一方为中国公民,本人出生在外国,具有中国国籍;但父母
双方或一方为中国公民并定居在外国,本人出生时即具有外国国籍的,不具有中国国籍。
Boolean 中国国籍法(具有中国国籍) (第五条)
if (父母双方或一方为中国公民)
{ if (本人出生在外国)
{ if (父母双方无永居)
{具有中国国籍;return ture}
else if (父母双方或一方永居)
{ if (本人出生时即具有外国国籍的)
... 阅读全帖
d******o
发帖数: 2489
17
来自主题: SanFrancisco版 - 请教如何给软件加个license (转载)
很多方法吧,从registry、系统文件里边,不过都会被破解。
如果你用C#,试一下:
// adding trial period for the application
// set for 30 days on initial launch
Option Explicit
Private Const TRIAL_PERIOD_DAYS As Integer = 30
Private Function TrialPeriodDaysLeft(DaysTrial As Integer) As Integer
Dim DateStart As Date
DateStart = GetSetting(App.Title, "Trial Period", "Date Start", 0)
If DateStart = 0 Then
SaveSetting App.Title, "Trial Period", "Date Start", Date
Else
TrialPeriodDaysLeft = DateDiff("d", DateStart, Date) > DaysTri... 阅读全帖
t*******r
发帖数: 22634
18
下面文字是针对楼主的这个帖子而言:
http://www.mitbbs.com/article/WaterWorld/2035975_0.html
喝口水继续。
那现在的问题是这个 P_fs 是啥东东。楼主肯定会说,当然是个 C 函数,
否则你是个傻瓜。:-) 那这个 C 函数跟高中数学函数是不是类似的东东,
可以互换呢?让俺们先回到 C 程序背后的 formal system。
P_fs 这个 C 函数,实际上是 C 语言背后概念上的 formal system
里面的一个 operator,这个 operator 的功能是把一个代表单个自然数
的 token 变成一个 boolean (0或1)类型的 token,根据该 boolean
token 可判断输入的单个自然数是不是素数。
<高潮就要来啦。。。不过先未完待续放段广告。。。>
t******n
发帖数: 2939
19
☆─────────────────────────────────────☆
l63 (l63) 于 (Thu May 23 00:34:22 2013, 美东) 提到:
假设素数只有有限个, 记为 p_1,p_2,...,p_k
考察 N = p_1*p_2*...*p_k + 1
可知: 对于任意i = 1,2,3,...,k, p_i 不能整除 N
由素数的定义:
a是素数 <=> a是大于1的自然数, 且a不被任何小于a的素数整除
可知: N是素数
这与素数只有p_1,p_2,...,p_k矛盾.
故假设不成立.
所以素数有无穷多个.
☆─────────────────────────────────────☆
l63 (l63) 于 (Thu May 23 00:37:03 2013, 美东) 提到:
在承认素数的这个等价定义 (即 a是素数 <=> a是大于1的自然数, 且a不被任何小于a
的素数整除) 的前提下, 居然有人会认为这个证明是错的, 或者是不完备的.
我实在不能理解.
求问一下大家, 是不是有的人的脑子天生有缺陷, 根本怎么教都不会明白... 阅读全帖
w***n
发帖数: 4358
20
来自主题: Hubei版 - [合集] 想死的心都有了
☆─────────────────────────────────────☆
somekiss (放开那个姑娘!) 于 (Mon Sep 20 16:26:19 2010, 美东) 提到:
又忘記拉拉鍊
☆─────────────────────────────────────☆
wowowowo (可持续发展) 于 (Mon Sep 20 16:31:50 2010, 美东) 提到:
as long as you wore underwear, no biggie

☆─────────────────────────────────────☆
somekiss (放开那个姑娘!) 于 (Mon Sep 20 16:35:07 2010, 美东) 提到:
謝謝安慰。。。
☆─────────────────────────────────────☆
happymichael (something new) 于 (Mon Sep 20 16:49:06 2010, 美东) 提到:
年纪大了都这样
☆──────────────────────... 阅读全帖
w***n
发帖数: 4358
21
来自主题: Hubei版 - [合集] 齐乔正vs蒋定邦
☆─────────────────────────────────────☆
wowowowo (可持续发展) 于 (Wed Sep 29 10:30:31 2010, 美东) 提到:
一个在外面长期包有情人,但是对老婆对儿子(非亲生)极尽温柔体贴包容扶持之能事
,凡事以家人为先,亦正亦邪
一个在外面没有情人,连其它女人都不正眼看一下,对老婆儿子也是可有可无自生自灭
,工作兄弟比身家性命还重要,一身正气
就算没有天壤之别的经济条件,你会愿意跟哪个?
☆─────────────────────────────────────☆
happymichael (something new) 于 (Wed Sep 29 10:34:37 2010, 美东) 提到:
真会挖坑

☆─────────────────────────────────────☆
thelishier (u r my angel) 于 (Wed Sep 29 13:44:42 2010, 美东) 提到:
so your question is shall we marry a man w... 阅读全帖
w***n
发帖数: 4358
22
☆─────────────────────────────────────☆
Viaaa (大V) 于 (Wed Oct 20 10:30:48 2010, 美东) 提到:
知道几乎每个宝宝都会有摔下床的经历,所以我妈,我婆婆和我都比较小心,毕竟美国
的床那么高,滚下来可不好玩。今天早上想把婆婆房里的空调出风口调一下,搬了个凳
子还是够不着(-_-|| 太矮),决定去把老公摇醒,看看闺女,穿着睡袋躺在queen
size床的正中间,估算一下,至少要连续一个方向翻2-3个身才会滚下床,于是一边和
正在其他房间找凳子的婆婆说“我去叫xx起来弄,你家别找了,没别的凳子”,一边走
到我的房间摇老公,刚刚摇了一下,听见娃哭,再听见婆婆跑过去哄,等我过去一看,
婆婆说闺女滚下来了 @#R$^^*&$%$ 。。。。
万幸的是,上周被我的朋友提醒娃滚下床的问题,周末我就找了一大床queen size的垫
被,套上被套,铺在婆婆的床边,让她白天把闺女放在地上垫被上玩(地毯太脏,怕她
啃),闺女这么一滚,正好落在垫被上,垫被下面是地毯,应该没怎么摔着。
早上上班路上给我妈打电话,如实坦白,被妈... 阅读全帖
w***n
发帖数: 4358
23
☆─────────────────────────────────────☆
Boolean (Soso) 于 (Thu Oct 21 13:38:43 2010, 美东) 提到:
不过看来,这里还风平浪静
http://www.mitbbs.com/news_wenzhang/Headline/31360979.html
☆─────────────────────────────────────☆
Viaaa (大V) 于 (Thu Oct 21 15:28:11 2010, 美东) 提到:
武汉科技大学到底是哪个大学啊,现在改了名字都搞不清楚了
☆─────────────────────────────────────☆
MiJie (MiJie) 于 (Thu Oct 21 15:52:28 2010, 美东) 提到:
以前就叫武汉科技大学,好像

☆─────────────────────────────────────☆
defu (无) 于 (Thu Oct 21 16:02:47 2010, 美东) 提到:
以前的武汉钢院和... 阅读全帖
w***n
发帖数: 4358
24
☆─────────────────────────────────────☆
aiyoaiyo (aiyoaiyo) 于 (Wed Dec 8 18:14:24 2010, 美东) 提到:
时不时看到有人在living版问,说油烟太大了.我真是想象不出这个油烟到底有多大,用
的都是啥油啥锅呀.另外我也想象不出在外面咋抄列,蹲着,还是站着? 还是象以前在读
书的时候搞个小酒精炉子放在板凳上,钩着腰炒? 要我lg这样要求,我真是回立马离. 板
砖吧.
☆─────────────────────────────────────☆
Boolean (Soso) 于 (Wed Dec 8 18:23:12 2010, 美东) 提到:
怎么没看出中心思想
受不了做饭,
受不了做饭的人?
☆─────────────────────────────────────☆
aiyoaiyo (aiyoaiyo) 于 (Wed Dec 8 18:30:57 2010, 美东) 提到:
受不了在院子里做饭,有橱房不用!

☆───────────────────────... 阅读全帖
w***n
发帖数: 4358
25
☆─────────────────────────────────────☆
teaheart (teaheart) 于 (Thu Sep 29 22:39:21 2011, 美东) 提到:
头10个re
☆─────────────────────────────────────☆
redalarm19 (pp) 于 (Thu Sep 29 22:47:14 2011, 美东) 提到:
赶紧
bless
☆─────────────────────────────────────☆
wowowowo (life is a journey) 于 (Thu Sep 29 23:09:46 2011, 美东) 提到:
re

☆─────────────────────────────────────☆
teaheart (teaheart) 于 (Thu Sep 29 23:12:38 2011, 美东) 提到:
谢谢4wo,希望有个offer
☆─────────────────────────────────────☆
fxxy (伤不... 阅读全帖
w***n
发帖数: 4358
26
☆─────────────────────────────────────☆
Boolean (Soso) 于 (Wed Oct 26 21:40:58 2011, 美东) 提到:
外面四爷党 和八爷党 拉帮结派 弄得不亦乐乎
这里怎么没动静?
你喜欢四爷多点还是八爷多点? 或者十三,十四?
☆─────────────────────────────────────☆
rcf (hello world) 于 (Wed Oct 26 21:44:06 2011, 美东) 提到:
都快旧闻啦!

☆─────────────────────────────────────☆
whbin (御风~探花) 于 (Wed Oct 26 22:30:39 2011, 美东) 提到:
hehe
☆─────────────────────────────────────☆
Helloroad (好ID就是好人吗) 于 (Wed Oct 26 22:43:08 2011, 美东) 提到:
不是现在都在看倾世皇妃嘛?!
☆───────────────────... 阅读全帖
w***n
发帖数: 4358
27
☆─────────────────────────────────────☆
aiyoaiyo (上班就是打酱油) 于 (Mon Oct 31 14:14:46 2011, 美东) 提到:
http://www.huaren.us/dispbbs.asp?boardid=358&id=1068171&page=0&
华人上有个明星和娃的万圣节造型都好cute.
☆─────────────────────────────────────☆
hikari (nana) 于 (Mon Oct 31 23:31:04 2011, 美东) 提到:
买了个青蛙服 太大了
结果今天干脆忘穿了

☆─────────────────────────────────────☆
hikari (nana) 于 (Mon Oct 31 23:35:19 2011, 美东) 提到:
顶盖盖
☆─────────────────────────────────────☆
hikari (nana) 于 (Mon Oct 31 23:36:42 2011, 美东) 提到... 阅读全帖
g**d
发帖数: 16
28
来自主题: CS版 - 若问JAVA问题~
&& is a conditional AND operator. Both operands should have Boolean types.
int type can't be automatically converted to boolean type, so a && b can't
be compiled while a and b are int.
l******9
发帖数: 579
29
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: error .mdf file unable to attach in Visual Studio 2013 win 7
发信站: BBS 未名空间站 (Mon Feb 16 19:26:34 2015, 美东)
I am working on RESTful Web services design in Visual Studio 2013 on Windows
7.
I need to run the command of Update-Database to create the database in code-
first migrations in a project.
But I get an error:
System.Data.SqlClient.SqlException : Cannot attach the file 'C:MyPathApp
_DataProductReview_newContext-2015... 阅读全帖
a****2
发帖数: 85
30
来自主题: Database版 - ORA-04030: out of process memory
The oracle database 10.2 report the following error message:
ORA-04030: out of process memory when trying to allocate 254488 bytes (QERGH
hash-agg,kllcqas:kllsltba)
**********************
but all the parameters don't give any evidence to support the lack of memory
, anyone can help?
Environment:
Window OS 2003, Oracle 10.2, 24G total RAM, 20G sga, 15G pga aggregate.
sga:
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size ... 阅读全帖
c**t
发帖数: 2744
31
来自主题: DotNet版 - Windows filesystem bug
I was pulling my hair out while try to resolve the follow exception
using(StreamWriter sw = new StreamWriter(fileName, false))
{
sw.Write(someString);
sw.Close();
};
it's because the fileName has ':' in it!! great bug!!
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path,
Boolean needFullPath)
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(
String[] str, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(
Fi
r*****n
发帖数: 92
32
来自主题: DotNet版 - Newbie ASP.NET question
I used sqlhelper class from Application block.
"ses" is my session variable class and ses.s is temporary session variable.
below is the code:
/*method validUserID is to verify id*/
Public Shared Function validUserID(ByVal userid As String) As Boolean
ses.s = (SqlHelper.ExecuteScalar(db.db_connection, CommandType.
StoredProcedure, sp.dptValidateUserID, New SqlParameter("@Userid", userid)))
db.CloseIfOpen()
If userid = ses.s Then
ses.UserId = userid
... 阅读全帖
l******9
发帖数: 579
33
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: error .mdf file unable to attach in Visual Studio 2013 win 7
发信站: BBS 未名空间站 (Mon Feb 16 19:26:34 2015, 美东)
I am working on RESTful Web services design in Visual Studio 2013 on Windows
7.
I need to run the command of Update-Database to create the database in code-
first migrations in a project.
But I get an error:
System.Data.SqlClient.SqlException : Cannot attach the file 'C:MyPathApp
_DataProductReview_newContext-2015... 阅读全帖
o****h
发帖数: 58
34
来自主题: Java版 - 这道题该走什么路

//要求做成一个method, 于是,偶这样
class Collie extends Dog{
public boolean isa(String className){ //需要全路径,如java.lang.Object
Collie param=new Collie();
try {
Class SomeClass = Class.forName(className);
// System.out.println(SomeClass);
Object obj = SomeClass.newInstance();
obj=(SomeClass)param; // 这里总是有问题呢,该怎么办 ???
return true;}
catch(Exception e){return false;}
}
}
另外一种方法倒是没问题,并且不必输入全路径,但好像烦了很多
class Collie extends Dog{
public boolean isa(String className){
v**o
发帖数: 64
35
来自主题: Java版 - Re: connection pool
import java.sql.*;
import java.util.*;
/**
* 连接池的实现
* @author: vago
*/
public class ConnectionPool implements Runnable {
private String driver, url, username, password;
private int maxConnections;
private boolean waitIfBusy;
private Vector availableConnections, busyConnections;
private boolean connectionPending = false;
/**
* 构造子
* @param driver java.lang.String
* @param url java.lang.String
* @param username java.lang.String
* @param password jav
xt
发帖数: 17532
36
来自主题: Java版 - Stupid IBM JDK
class Util {
public boolean compareFile( File f1, File f2 )
{ // Read and compare content of file }
} // end class Util
class Test
{
...
if( !Util.compareFile( f1, f2 ) ) {
System.out.println( "Different" );
}
boolean same = Util.compareFile( f1, f2 );
if( same ) {
System.out.println( "Same" );
}
...
}
Use f1 and f2 pointing 2 identical files
Result:
Different
Same
m******t
发帖数: 2416
37
来自主题: Java版 - Stupid IBM JDK

Well then I didn't miss your point. So can you reduce this to something like:
boolean foo() { return true; }
if (!foo()) System.out.println("false");
boolean fooRes = foo();
if (fooRes) System.out.println("true");
v******e
发帖数: 63
38
来自主题: Java版 - Stupid IBM JDK
I don't like IBM, but I can't agree with you on this one. Looks like your
check() method is not idempotent. Check this :
boolean check1 = check(arg1, arg2);
boolean check2 = check(arg1, arg2);
System.out.println("check1:" + check1 + " check2:" + check2);

they
not
g*****g
发帖数: 34805
39
It's performance issue that holded the designers back from implementing any
collection interface.
Boolean value is stored as a bit in integer and it will be very expensive to
implement method like remove(int index).
The BitSet is only good for store large array of boolean values with trading
performance for space in mind.





a****8
发帖数: 1
40
public class Z {
int a, b;
public boolean test(){ // <--1
if( a>= 0 ) { return a >= b;
} else { return a == b; }
}
public boolean test() { // <-- 2
int i = a - b;
return i >= 0;
}
}
1和2,哪个更强地保持了a,b不变。
面试题。
初看,好像2。
可1也没什么大问题。
哪位有高见?
g*****g
发帖数: 34805
41
Just use one level of indirection. e.g. have a class called Variable
class Variable {
boolean changed;
Object value;
public boolean setValue(Object value) {
if(changed) {
return false;
else {
this.value = value;
return true;
}
}
}
Then declare 10 instances.

3nd
z***e
发帖数: 5393
42
就是要在production上设一个debug flag,然后把所有细节都能log下来。
问题是这个所有细节就有很多,而且很多步。
本来简单的做法就是
void debug(boolean debugFlag, String message) {
if (debugFlag) {
log(message);
}
}
那么caller就会有很多种这种:
debug(flag, "Data1: "+ ...+....+...);
debug(flag, "Data2: "+ ...+....+...);
debug(flag, "Data3: "+ ...+....+...);
但是如果没有设置debugflag,我不知道"Data1: "+ ...+....+...这种string concat
会不会执行。如果是C/C++的话,这种直接inline就好了,但是java又不能inline。
我把它改成:
void debug(boolean debugFlag, String... message) {
...

然后在里面再去concat string,这样是不是好点?
c*********e
发帖数: 16335
43
来自主题: Java版 - 工作中遇到的并行处理问题
好奇地问一下,这些class是用在web application里,还是application里?
如果是web application里,每一個用戶登录进去后,private boolean inited的值,
每个用戶都能更改,因为它不是session variable.这个大家怎么解决的?
public class Predictor {
private boolean inited = false;

出。
p*****3
发帖数: 488
44
来自主题: Java版 - Skyline
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
public class EPI_15_1 {
static class Rect {
public int lft;
public int rgt;
public int height;

public Rect(int l, int r, int h) {
lft = l;
rgt = r;
height = h;
}
}

static class Point {
... 阅读全帖
l*******g
发帖数: 82
45
来自主题: Java版 - HashMap一问
你之所以那个get() != true出现null pointer exception是因为jvm试图先吧返回值转
化成Boolean,所以你就看见了这个exception。

我有个HashMap hm如果某个ListNode ln没有被
push进这个hashmap,那么hm.get........
S******1
发帖数: 216
46
/**
* Definition for a point.
* class Point {
* int x;
* int y;
* Point() { x = 0; y = 0; }
* Point(int a, int b) { x = a; y = b; }
* }
*/
public class Solution {

class Line {
boolean vertical = false;
double slop = 0.0;
double intercept = 0.0;

public Line(Point pt1, Point pt2) {
if (pt1.x == pt2.x)
{
vertical = true;
intercept = pt1.x;
}
else
... 阅读全帖
s****i
发帖数: 857
47
最近写了个代码学习一下外部类,内部类使用.一直有奇怪的问题没解决,这个胸闷啊
。用的是Eclipse,java。
代码结构式:
定义一个外部类whiletest,有一个boolean型的成员变量testhappen。定义一个内部类
Timer,内部类作为单独的线程每隔500ms改变一下testhappen的值(true/false)。
同时外部类的实例化对象调用print()是个死循环,一直打印testhappen的值。
按理说应该是当testhappen被Timer变为true之后,print()有输出;变为false之后,
print()没有输出。可是我运行时就是没有print()的输出。
奇怪的是什么,我在print()里面设置一个断电,debug调试的时候竟然能停下来。
总之就是正常全速运行不好使,debug没问题。
这个问题真是个小虫子,难受啊。
//Outerclass
public class whiletest {

boolean testhappen = true;
int i = 0;

void... 阅读全帖
z****e
发帖数: 54598
48
但是properties有一个局限就是所有的value都是string
这个需求需要对int, boolean这些做自动转换
显然json & jackson会更容易点
比如读取这种文件
useMulti: false
wait: 1000
ip: 127.0.0.1
jackson可以直接存成
boolean, int & string对象
如果是properties,就要挨个parse过去,然后一堆的try, catch
挺折腾的,其实做到最后就是rebuild一个jackson
还不如直接down下来用了

spring
动。
d**********g
发帖数: 1146
49
来自主题: Java版 - 关于new operator的问题
基本功不扎实,请大家指点
在SaveAsDependencyAndEditJSTableProcessor class中,我定义了一个class变量
useLocationOfSourceObject ,如何在SaveAsDependencyAndEditJSTableProcessor
中的new LocationDataHandler()中使用该class变量?
下面代码中的this.this$0.useLocationOfSourceObject是我decode的结果
public class SaveAsDependencyAndEditJSTableProcessor extends
UIExtCollectionJSTableProcessor{
**********************
private boolean useLocationOfSourceObject = true;
final LocationDataHandler local1SaveAsLocationDataHandler = new
LocationDataHan... 阅读全帖
l********l
发帖数: 4
50
I assume you want W1, W2, W3... all have no shared characters.
There are maximum 26 words in this sequence.
Input: W1 (the word), Dictionary
steps:
boolean appeared[26]= new boolean[26];
for (char ch : W1)
appeared[ch] = true;
For (String word : Dictionary) {
goodWord = true;
for (char ch : word) {
if (appeared[ch]) {
goodWord = false;
break;
}
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)