我正在寻找一些模拟的OCJP问题.我遇到了一个非常莫名其妙的语法.这里是:
class OddStuff {
public static void main(String[] args) {
boolean b = false;
System.out.println((b != b));// False
System.out.println((b =! b));// True
}
}
Run Code Online (Sandbox Code Playgroud)
为什么输出在!=和之间变化=!?
我做了一个全新的项目.我已将项目添加到menu布局文件中.这些项目不会显示在操作栏的右侧.我记得有一个带有三个点的图标会打开菜单.

这是我的 Activity
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.BLUE));
actionBar.show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_option1"/>
<item
android:id="@+id/action_settings34"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_option2"/>
<item
android:id="@+id/action_settings3"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_option3"/>
</menu>
Run Code Online (Sandbox Code Playgroud) 我的文件夹中有四个java文件.它们都在同一个包装中.这是包装声明
package com.osama.GHide
所有这些类都在同一个包中.我想知道如何使用它编译它们javac(我的意思是我不知道如何编译彼此使用的多个文件).一旦完成,我如何java在CLI中使用命令启动?这是文件名.
EnteringPoint.java
HidingProcess.java
ListFiles.java
我一直试图为我的文本改变事件处理机制JTextArea.为了我的目的,只要文本发生变化,就必须触发事件JTextArea.我尝试使用KeyListener界面,这是我的代码.
txtArea.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent arg0) {
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent arg0) {
currentText = text.getText();
if (currentText == textString)
JOptionPane.showMessageDialog(null, "Correct");
}
});
Run Code Online (Sandbox Code Playgroud)
当textarea的文本与硬编码文本匹配时,什么都没发生.如何为此事件改变事件.
这个目标能否实现PropertyChangedListener?如果可以,那怎么样?
我想让我的Java应用程序在按下"关闭"十字按钮时调用我自己的自定义函数.据我所知,可能没有办法,因为setDefaultCloseOperation根本没有超载.
知道如何实现这一目标吗?
我是php的n00b.我正在学习默认参数,所以我做了这个功能.
function doFoo($name = "johnny"){
echo "Hello $name" . "<br />";
}
Run Code Online (Sandbox Code Playgroud)
我做了这些电话
doFoo();
doFoo("ted");
doFoo("ted", 22);
Run Code Online (Sandbox Code Playgroud)
前两个印刷了预期的即
Hello johnny
Hello ted
Run Code Online (Sandbox Code Playgroud)
但第三次电话也印了
Hello ted
Run Code Online (Sandbox Code Playgroud)
在为一个参数创建所有函数之后,我期待一个错误,而我用两个参数调用它.
为什么没有错误?
我的公司没有中央git服务器,也没有允许我使用BitBucket等.
无论如何我可以使用我的localhost remote吗?
编辑:我在一台Windows机器上
可能重复:
PHP页面重定向
一旦进程完成,我如何重定向到php中的另一个页面.
例如,我的<form>标签将action属性设置为"process.php".在process.php上的进程完成后,我希望它重定向到它所从的站点.怎么做的?
我在服务器上有一个文本文件(.txt).它只包含一个字,即ON或OFF.我如何使用JQuery或Pure Javascript从文件中读取该单词.
我正在思考 $.ajax.
好的,这就是我发送的意图
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
startActivityForResult(intent, REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)
然后在onActivityResult中我这样做:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i("Intent name:",data.toString());
if (requestCode == REQUEST_CODE){
if (resultCode == Activity.RESULT_OK){
Toast.makeText(this, "Image saved to \n" + fileUri.toString() , Toast.LENGTH_LONG).show();
Toast.makeText(this, "Result Code: " + resultCode , Toast.LENGTH_LONG).show();
//Bitmap mBitMap = BitmapFactory.decodeFile(data.getData().toString());
//imageView.setImageBitmap(mBitMap);
}
else if (resultCode == RESULT_CANCELED){
Toast.makeText(this, "Capture Cancelled", Toast.LENGTH_LONG).show();
} …Run Code Online (Sandbox Code Playgroud)