假设我有三个班级:
class A {
A() {
// super();
System.out.println("class A");
}
}
class B extends A {
B() {
// super();
System.out.println("class B");
}
}
class C extends B {
public static void main(String args[]) {
C c = new C(); //Parent constructor will get called
}
}
Run Code Online (Sandbox Code Playgroud)
当我创建一个C类实例时,它会调用超类的构造函数.那么,是否有多个对象被创建?如果只创建了一个对象,那么super()和另一个类的构造函数如何?super()方法是否在内部创建了一个对象?我所知道的是,构造函数也是一种方法(我可能错了).
我的问题是:
我的导师告诉我主线程是每个线程的父线程,但他无法解释原因.
当我写一个简单的程序时:
Class A{}
Run Code Online (Sandbox Code Playgroud)
然后它在执行时抛出异常:
java.lang.NoSuchMethodError: main Exception in thread "main"
Run Code Online (Sandbox Code Playgroud)
main()方法和主线程之间有什么关系吗?
我是Bitbucket管道(Beta)和docker的新手.没有以前的CI集成经验
我跟着这个问题,但对初学者没有明确的描述
我正在尝试使用docker容器在Android项目的Bitbucket管道中设置持续集成(CI)
我想在这个容器中使用我以前的android项目
我遵循的步骤
第1步.已安装的Docker软件工具.成功安装.
第2步.成功创建虚拟机
第3步.从Kitematic(Beta)Uber/Android-Build-Environment创建容器
第4步.使用成功构建项目
$ eval "$(docker-machine env default)"
$ docker build -t uber/android-build-environment .
Run Code Online (Sandbox Code Playgroud)
第5步.改变直接工作到android项目
步骤6.运行此命令时出现问题
docker run -i -v $PWD:/project -t uber/android-build-environment /bin/bash /project/ci/build.sh
Run Code Online (Sandbox Code Playgroud)
错误来了:
/bin/bash: /project/ci/build.sh: No such file or directory
Docker机器细节
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 v1.12.1
Run Code Online (Sandbox Code Playgroud)
Docker服务
docker service ls
Run Code Online (Sandbox Code Playgroud)
Docker Machine ENV
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.XX.XXX:XXXX"
export …Run Code Online (Sandbox Code Playgroud) continuous-integration android continuous-deployment bitbucket-pipelines
我正在尝试通过我在Nexus 5中安装的应用程序连接设备.我想在android中创建类似彩虹联系人的应用程序.在我的应用程序中,我的目标是通过蓝牙连接到另一台设备并传输一组联系人或文件.我遵循了这个问题,但提到的解决方法对我不起作用 这是我的完整代码.这是我的应用程序的代码片段,我试图获取套接字并建立连接.
我能够通过配对设备对话框,但是当我尝试配对时,会引发错误
//to create socket
if (secure) {
bluetoothSocket = device.createRfcommSocketToServiceRecord(uuid);
} else {
bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid);
}
//connection establishment
try {
bluetoothSocket.connect();
success = true;
break;
} catch (IOException e) {
//try the fallback
try {
Class<?> clazz = tmp.getRemoteDevice().getClass();
Class<?>[] paramTypes = new Class<?>[] {Integer.TYPE};
Method m = clazz.getMethod("createRfcommSocket", paramTypes);
Object[] params = new Object[] {Integer.valueOf(1)};
bluetoothSocket = (BluetoothSocket) m.invoke(tmp.getRemoteDevice(), params);
Thread.sleep(500);
bluetoothSocket.connect();
success = true;
break;
} catch (FallbackException e1) …Run Code Online (Sandbox Code Playgroud) 我正在研究用于删除网站的nodejs,我对nodejs很新.网站初始页面是一个弹出窗口,其中一个必须从selectbox中选择选项并提交,然后才能浏览以后的页面.这必须首先完成时间然后它将被存储为cookie供以后使用.
我能够获得弹出窗口的html页面但我无法从selectbox中选择选项并提交请求.
这是我的代码
var express = require('express');
var request=require('request');
var cheerio=require('cheerio');
var j = request.jar();
//var cookie = request.cookie();
j.setCookie("city_id=1; path=/; domain=.bigbasket.com", 'http://bigbasket.com/', function(error, cookie) {
//console.log("error"+error.message);
console.log("cookie "+cookie);
});
var app=express();
app.get('/', function(req, res){
console.log("hi");
var sessionVal = req.session;
request({uri:'http://bigbasket.com/',
headers:{'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36' ,
'content-type':'application/x-www-form-urlencoded; charset=UTF-8',
'connection':'keep-alive'},
jar:j},
function(err, response, body) {
// console.log("err "+err.message);
console.log("header"+JSON.stringify(response.headers));
console.log("status"+response.statusCode);
console.log("cookie "+response.cookie);
console.log(body);
var $=cheerio.load(body,{xmlMode: true});
console.log($);
var $selectBox= $('select').filter('.selectboxdiv');
console.log($selectBox.text());
response.end;
}); …Run Code Online (Sandbox Code Playgroud) 我跟进了这个问题,但所有提到的解决方案对我都不起作用.
我正在制作类似于彩虹应用程序的应用程序.此应用程序将安装在必须将所有联系人发送到其他设备的设备中.该应用程序仅安装在一个设备中.我可以通过这段代码连接到远程设备
// BluetoothConnector(完整代码)
Class<?> clazz = tmp.getRemoteDevice().getClass();
Class<?>[] paramTypes = new Class<?>[] {Integer.TYPE};
Method m = clazz.getMethod("createRfcommSocket", paramTypes);
Object[] params = new Object[] {Integer.valueOf(1)};
fallbackSocket = (BluetoothSocket) m.invoke(tmp.getRemoteDevice(), params);
Run Code Online (Sandbox Code Playgroud)
在完成配对请求并完成连接后,我尝试通过这段代码通过outputstream将数据发送到其他设备.
//输出流代码(完整代码)
public void write(byte[] buffer) {
try {
Log.i(TAG, "write");
mmOutStream.write(buffer);
} catch (IOException e) {
Log.e(TAG, "Exception during write", e);
}
Run Code Online (Sandbox Code Playgroud)
但我无法尽快发送mmOutStream.write(缓冲区)数据; 被称为它给出以下错误.
//错误日志(完整日志)
09-21 16:21:52.829 6262-6262/com.example.aadi.myapplication D/BT_app? connection_done
09-21 16:21:52.829 6262-6871/com.example.aadi.myapplication I/BT_app? BEGIN mConnectedThread
09-21 16:21:52.829 6262-6871/com.example.aadi.myapplication I/BT_app? write
09-21 …Run Code Online (Sandbox Code Playgroud) java ×4
android ×3
bluetooth ×2
connection ×1
constructor ×1
html ×1
javascript ×1
jquery ×1
node.js ×1
object ×1
sockets ×1
web-crawler ×1