我正在使用 web3 使用以下方法连接到元掩码
await window.ethereum.request({ method: 'eth_requestAccounts' });
var address = await window.ethereum.request({ method: 'eth_accounts' });
Run Code Online (Sandbox Code Playgroud)
但是当我刷新屏幕时它仍然显示为已连接,我无法在 web3 中找到任何方法将其与 pancackeswap 等网站断开连接
我想从中访问所有方法(非抽象+抽象)Class A.
所以我扩展了Class A,但在这里,Class B我想访问所有非抽象方法,只有10个抽象方法 - 因为我不想实现其余的抽象方法class B.
问题:
我不能延长,Class B因为我已经延长了Class A.
2.我不能将这10个方法放在接口中,因为我也想从中访问非抽象方法class B.
什么应该是重用这些方法的正确方法?
A级
abstract class A{
public void m1(){
//do stuff
}
public void m2(){
//do stuff
}
// +30 more non abstract methods
public abstract void n1();
public abstract void n2();
// +30 more abstract method
}
Run Code Online (Sandbox Code Playgroud)
B级
abstract class B{
public void a1(){
//do stuff
}
public void a2(){
//do …Run Code Online (Sandbox Code Playgroud) 我刚刚遇到了一段代码。在一种情况下,我无法使用其实例访问类的私有成员(这很好),但在其他情况下,我能够使用其不同的实例访问私有成员(属于同班)。谁能解释一下为什么会发生这种情况?
class Complex {
private double re, im;
public String toString() {
return "(" + re + " + " + im + "i)";
}
Complex(){}
/*Below c is different instance, still it can access re,im( has a private access)
without any error.why? */
Complex(Complex c) {
re = c.re;
im = c.im;
}
}
public class Main {
public static void main(String[] args) {
Complex c1 = new Complex();
Complex c2 = new Complex(c1);
System.out.println(c1.re); /* But getting an …Run Code Online (Sandbox Code Playgroud) java ×2
oop ×2
blockchain ×1
inheritance ×1
installation ×1
interface ×1
java-8 ×1
metamask ×1
reactjs ×1
web3js ×1