小编Pri*_*nka的帖子

方法重载时Java方法继承问题

这是我检查 Java 继承和方法重载的简单代码。它在我的 IDE 中给出了编译错误。你能不能给一个想法。?代码中注释了错误行。如果我评论该行程序工作正常并提供给定的输出。

class Bird {
    void sing() {
        System.out.println("I am Singing");
    }
}
class Peacock extends Bird {
    void sing() {
        System.out.println("I am Singing COO COO");
    }

    public void sing(String adverb) {
        System.out.println("I am Singing " + adverb);
    }
}
public class OverLoadingDemo {

    public static void main(String[] args) {
        Bird bird = new Peacock();
        bird.sing();//This return I am Singing COO COO
        bird.sing("Loudly");//ERROR The method sing() in the type Bird is not applicable for the arguments (String) …
Run Code Online (Sandbox Code Playgroud)

java oop

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

使用JAVA从混合字符串中提取Json字符串

我有一个很大的文本文件。它混合了更多的行和各种信息

我的要求是从下面的混合字符串行检索 json

线 :

PID: [0] [STM] [2016-12-01 00:00:00,135]  INFORMATION {com.priyan.JsonParser} -  My Req Body: { "amountTxn": { "paymentAmt": { "amtReserved": null, "totalAmtCharged": null, "chargingData": { "taxAmt": 10, "categoryCode": "MyApp" }, "totalAmountRefunded": null, "chargingInformation": { "amount": 1.5, "description": ["Test 01 (demo)"] } }, "userId": "tel:+2313215", "txnStatus": "Charged", "origCode": null, "seq": null } } TOKEN ID: 351351 {com.priyan.JsonParser}
Run Code Online (Sandbox Code Playgroud)

我只需要提取这个json部分

{ "amountTxn": { "paymentAmt": { "amtReserved": null, "totalAmtCharged": null, "chargingData": { "taxAmt": 10, "categoryCode": "MyApp" }, "totalAmountRefunded": null, "chargingInformation": { "amount": …
Run Code Online (Sandbox Code Playgroud)

java json gson

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

标签 统计

java ×2

gson ×1

json ×1

oop ×1