0xFFFFFFF1是什么意思?

xihuanni0509 2011-04-26 01:46:06
public class test (
  2. public static void main (String args[]) {
  3. int i = 0xFFFFFFF1;
  4. int j = ~i;
  5.
  6. }
  7. )
  What is the decimal value of j at line 5?
  A. 0
  B. 1
  C. 14
  D. –15
  E. An error at line 3 causes compilation to fail.
  F. An error at line 4 causes compilation to fail.
  Answer: C
...全文
3080 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
lliiqiang 2011-04-28
  • 打赏
  • 举报
回复
十六机制写法,~代表二进制取反
xihuanni0509 2011-04-28
  • 打赏
  • 举报
回复
我今天看原码又发现一个东东,请各位指点一下这个用法是个什么意思:
public ButtonObject(String strName)
{
this(strName, strName);
}


package nc.ui.pub;

import java.util.ArrayList;
import java.util.Vector;

public class ButtonObject
{
private String m_strName;
private String m_strHint;
private int m_nPower;
private ButtonObject m_boParent;
private Vector m_vecChildren;
private boolean m_bEnabled;
private boolean m_bVisible;
private boolean bUnionFunc;
private ArrayList alUnionFuncbtn;
private boolean m_bPower;
private Object m_data;
private String m_internalTag;
private int m_intModifiers;
private boolean m_isCheckboxGroup;
private boolean m_isExclusiveMode;
private boolean m_isPowerContrl;
private boolean m_isSelected;
private boolean m_isSeperator;
private String m_strCode;
private String m_strDisplayHotkey;
private String m_strHotKey;
private String m_strTag;

public ButtonObject(String strName)
{
this(strName, strName);
}

public ButtonObject(String name, ButtonObject[] children)
{
this(name);
addChileButtons(children);
}

public ButtonObject(String name, String hint)
{
this(name, hint, 0);
}

public ButtonObject(String name, String hint, int power)
{
this.m_strName = null;

this.m_strHint = null;

this.m_nPower = 0;

this.m_boParent = null;

this.m_vecChildren = null;

this.m_bEnabled = true;

this.m_bVisible = true;

this.bUnionFunc = false;

this.m_bPower = true;
this.m_data = null;

this.m_internalTag = null;
this.m_intModifiers = -1;

this.m_isCheckboxGroup = false;

this.m_isExclusiveMode = true;

this.m_isPowerContrl = true;

this.m_isSelected = false;

this.m_isSeperator = false;
this.m_strCode = null;
this.m_strDisplayHotkey = null;

this.m_strHotKey = null;

this.m_strTag = null;

this.m_strName = name;
this.m_strHint = hint;
this.m_nPower = power;
this.m_strCode = name;
this.m_internalTag = name + String.valueOf(Math.random());
}

public void addChildButton(ButtonObject bo)
{
bo.setParent(this);
getChildren().addElement(bo);
}

public ButtonObject[] getChildButtonGroup()
{
ButtonObject[] bos = new ButtonObject[getChildren().size()];
return ((ButtonObject[])getChildren().toArray(bos));
}

public Vector getChildren()
{
if (this.m_vecChildren == null)
try {
this.m_vecChildren = new Vector();
} catch (Throwable e) {
//handleException(e);
}

return this.m_vecChildren;
}

public String getHint()
{
return this.m_strHint;
}

public String getName()
{
return this.m_strName;
}

public ButtonObject getParent()
{
return this.m_boParent;
}

public int getPower()
{
return this.m_nPower;
}

// private static void handleException(Throwable exception)
// {
// ClientEnvironment.getInstance().handleException(exception);
// }

public boolean isEnabled()
{
return this.m_bEnabled;
}

public boolean isVisible()
{
return this.m_bVisible;
}

public void removeAllChildren()
{
getChildren().removeAllElements();
}

public void removeChildButton(ButtonObject bo)
{
getChildren().remove(bo);
}

public void setChildButtonGroup(ButtonObject[] bos)
{
Vector children = getChildren();

children.removeAllElements();
if (bos != null)
for (int i = 0; i < bos.length; ++i)
children.addElement(bos[i]);
}

public void setEnabled(boolean b)
{
this.m_bEnabled = b;
}

public void setHint(String strHint)
{
this.m_strHint = strHint;
}

public void setName(String newvalue)
{
this.m_strName = newvalue;
}

public void setParent(ButtonObject newvalue)
{
this.m_boParent = newvalue;
}

void setPower(int nPower)
{
this.m_nPower = nPower;
}

public void setVisible(boolean visi)
{
this.m_bVisible = visi;
}

public ButtonObject(String name, String hint, int power, String code)
{
this.m_strName = null;

this.m_strHint = null;

this.m_nPower = 0;

this.m_boParent = null;

this.m_vecChildren = null;

this.m_bEnabled = true;

this.m_bVisible = true;

this.bUnionFunc = false;

this.m_bPower = true;
this.m_data = null;

this.m_internalTag = null;
this.m_intModifiers = -1;

this.m_isCheckboxGroup = false;

this.m_isExclusiveMode = true;

this.m_isPowerContrl = true;

this.m_isSelected = false;

this.m_isSeperator = false;
this.m_strCode = null;
this.m_strDisplayHotkey = null;

this.m_strHotKey = null;

this.m_strTag = null;

this.m_strName = name;
this.m_strHint = hint;
this.m_nPower = power;
this.m_strCode = code;
this.m_internalTag = name + String.valueOf(Math.random());
}

public void addChileButtons(ButtonObject[] aryBtns)
{
if (aryBtns != null) {
getChildren().removeAllElements();
for (int i = 0; i < aryBtns.length; ++i)
addChildButton(aryBtns[i]);
}
}

public int getChildCount()
{
if (this.m_vecChildren == null)
return 0;

return getChildren().size();
}

public String getCode()
{
return this.m_strCode;
}

public Object getData()
{
return this.m_data;
}

public String getDisplayHotkey()
{
return this.m_strDisplayHotkey;
}

public String getHotKey()
{
return this.m_strHotKey;
}

public String getInternalTag()
{
return this.m_internalTag;
}

public int getModifiers()
{
return this.m_intModifiers;
}

public ButtonObject[] getSelectedChildButton()
{
ButtonObject[] bo = (ButtonObject[])null;

if ((isCheckboxGroup()) && (getChildCount() > 0))
{
ArrayList list = new ArrayList();
ButtonObject[] ary = getChildButtonGroup();
for (int i = 0; i < ary.length; ++i)
{
if (ary[i].isSelected())
{
list.add(ary[i]);
}
}
if (list.size() > 0)
{
bo = new ButtonObject[list.size()];
list.toArray(bo);
}
}
return bo;
}

public String getTag()
{
return this.m_strTag;
}

public boolean isCheckboxGroup()
{
return this.m_isCheckboxGroup;
}

public boolean isExclusiveMode()
{
return this.m_isExclusiveMode;
}

public boolean isPower()
{
return this.m_bPower;
}

public boolean isPowerContrl() {
return this.m_isPowerContrl;
}

public boolean isSelected()
{
return this.m_isSelected;
}

public boolean isSeperator()
{
return this.m_isSeperator;
}

public void setCheckboxGroup(boolean isCheckBoxGroup)
{
this.m_isCheckboxGroup = isCheckBoxGroup;
}

public void setCode(String newCode)
{
this.m_strCode = newCode;
}

public void setData(Object newData)
{
this.m_data = newData;
}

public void setDisplayHotkey(String newDisplayHotkey)
{
this.m_strDisplayHotkey = newDisplayHotkey;
}

public void setExclusiveMode(boolean mode)
{
this.m_isExclusiveMode = mode;
}

public void setHotKey(String newHotKey)
{
this.m_strHotKey = newHotKey;
}

public void setModifiers(int newModifiers)
{
this.m_intModifiers = newModifiers;
}

public void setPower(boolean newPower)
{
this.m_bPower = newPower;
}

public void setPowerContrl(boolean isPowercontrl) {
this.m_isPowerContrl = isPowercontrl;
}

public void setSelected(boolean isSelected)
{
this.m_isSelected = isSelected;
}

public void setSeperator(boolean isSeperator)
{
this.m_isSeperator = isSeperator;
}

public void setTag(String tag)
{
this.m_strTag = tag;
}

public void setUnionFuncFlag(boolean bFlag)
{
this.bUnionFunc = bFlag;
}

public boolean isUnionFunc() {
return this.bUnionFunc;
}

public void addUnionfuncbtn(ButtonObject btnobj)
{
if (this.alUnionFuncbtn == null)
this.alUnionFuncbtn = new ArrayList();

this.alUnionFuncbtn.add(btnobj); }

public ArrayList getUnionfuncbtn() {
return this.alUnionFuncbtn;
}

public String toString() {
return this.m_strName;
}



}
xihuanni0509 2011-04-28
  • 打赏
  • 举报
回复
明白了
wang_huanming 2011-04-26
  • 打赏
  • 举报
回复
十六进制码
IceArmour 2011-04-26
  • 打赏
  • 举报
回复
啊。。。不对不对,0X0000000E是14,,不是15,失误失误
IceArmour 2011-04-26
  • 打赏
  • 举报
回复
我靠,不是吧,0XFFFFFFF1是二进制整数,也是正数,~取反是取它的补码,0X0000000E,即15
ebonyzhang 2011-04-26
  • 打赏
  • 举报
回复
这个0x是十六进制的意思 i = 0xFFFFFFF1 这个是补码 ,原码是0x1000000F 化成十进制为-15
j为0xFFFFFFF1取反 为 0x0000000E 化成十进制为14。
24K純帥 2011-04-26
  • 打赏
  • 举报
回复
OX是16进制,把他转会为二进制的的再取反就是了
若鱼1919 2011-04-26
  • 打赏
  • 举报
回复

Integer的equals方法:
public boolean equals(Object obj) {
if (obj instanceof Integer) {//要想equals,必须得是同一个类型
return value == ((Integer)obj).intValue();
}
return false;
}
Long的equals:
public boolean equals(Object obj) {
if (obj instanceof Long) {
return value == ((Long)obj).longValue();
}
return false;
}
Double的equals:
public boolean equals(Object obj) {
return (obj instanceof Double)
&& (doubleToLongBits(((Double)obj).value) ==
doubleToLongBits(value));
}
  • 打赏
  • 举报
回复
ethenjean 2011-04-26
  • 打赏
  • 举报
回复
你看得什么书啊?显然书上是错误的答案,尽信书不如无书啊!
xihuanni0509 2011-04-26
  • 打赏
  • 举报
回复
  Integer i = new Integer (42);
  Long 1 = new Long (42);
  Double d = new Double (42.0);
  Which two expressions evaluate to True? (Choose Two)
  A. (i ==1)
  B. (i == d)
  C. (d == 1)
  D. (i.equals (d))
  E. (d.equals (i))
  F. (i.equals (42))
  Answer: D, E

可是我运行的结果是:

public static void main(String[] args) {
// TODO Auto-generated method stub


Integer i = new Integer (42);
Long l = new Long (42);
Double d = new Double (42.0);
double d2=42.0;


if(i.equals(d2)){
System.out.println("i.equals(d2)");
}else{
System.out.println("!i.equals(d2)");
}
if(d.equals(i)){
System.out.println("d.equals(i)");
}else{
System.out.println("!d.equals(i)");
}
if(i.equals(42)){
System.out.println("i.equals(42)");
}

}


!i.equals(d2)
!d.equals(i)
i.equals(42)




Franklin_007 2011-04-26
  • 打赏
  • 举报
回复
这个0x是十六进制的意思 i = 0xFFFFFFF1 这个是补码 ,原码是0x1000000F 化成十进制为-15
j为0xFFFFFFF1取反 为 0x0000000E 化成十进制为14
出家二少 2011-04-26
  • 打赏
  • 举报
回复
0xFFFFFFF1是十六进制的整数 0x开头代表是十六进制 FFFF FFF1
[Quote=引用楼主 xihuanni0509 的回复:]
public class test (
2. public static void main (String args[]) {
3. int i = 0xFFFFFFF1;
4. int j = ~i;
5.
6. }
7. )
What is the decimal value of j at line 5?
A. 0
B. 1
C. 14
D. –15
E. An e……
[/Quote]
学习Java中 2011-04-26
  • 打赏
  • 举报
回复

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧