相关疑难解决方法(0)

Java中的super()

super()用来调用父类的构造?请解释一下super().

java super

215
推荐指数
6
解决办法
48万
查看次数

对于类变量,向上转换和向下转换有什么区别

对于类变量,向上铸造和向下铸造有什么区别?

例如,在下面的程序类中,Animal只包含一个方法但Dog类包含两个方法,那么我们如何将Dog变量转换为Animal变量.

如果完成了施法,那么我们如何使用Animal的变量调用Dog的另一种方法.

class Animal 
{ 
    public void callme()
    {
        System.out.println("In callme of Animal");
    }
}


class Dog extends Animal 
{ 
    public void callme()
    {
        System.out.println("In callme of Dog");
    }

    public void callme2()
    {
        System.out.println("In callme2 of Dog");
    }
}

public class UseAnimlas 
{
    public static void main (String [] args) 
    {
        Dog d = new Dog();      
        Animal a = (Animal)d;
        d.callme();
        a.callme();
        ((Dog) a).callme2();
    }
}
Run Code Online (Sandbox Code Playgroud)

java casting downcast upcasting class-variables

124
推荐指数
7
解决办法
28万
查看次数

如何在AndroidManifest.xml中注册新活动?

当我运行我创建的应用程序时,我总是遇到错误,根据我的研究,我没有在清单中注册我的Activity.如何在AndroidManifest.xml中注册新活动?

android

9
推荐指数
3
解决办法
3万
查看次数

为什么我的SQL create语句导致我的应用程序崩溃?

错误信息:

android.database.sqlite.SQLiteException: near "transaction": syntax error (code 1): , while compiling: **create table transaction ( _id integer primary key autoincrement, amount real, type varchar(20), date integer)
Run Code Online (Sandbox Code Playgroud)

我的应用程序存储由自动生成的ID,花费的金额,付款类型和日期组成的货币交易.我的应用程序编译正常,但是当我尝试运行数据库是sqlite数据库的活动时,应用程序崩溃了上面的消息.至于我意识到我的SQL语句是有效的,任何人都可以提供任何可能是原因的洞察力吗?

Java代码:

 db.execSQL("create table transaction (" +
        " _id integer primary key autoincrement, amount real, type varchar(20), date integer)");
Run Code Online (Sandbox Code Playgroud)

谢谢

java sqlite android android-sqlite

1
推荐指数
1
解决办法
151
查看次数

如何在现有Android应用程序中使用Kotlin?

我有一个使用Java开发的Android应用程序.我现在想开始在同一个应用程序中使用Kotlin.是否可以在现有应用程序中并排使用Kotlin和Java?

kotlin

0
推荐指数
3
解决办法
3311
查看次数