我有一个带有方法的类,它返回一个字符串。如果我创建一个对象并调用该方法,则该对象包含该类的ID(com.ma.singhalja.testclass.greeting@99e92d)
package com.ma.singhalja.testclass;
import android.app.Application;
public class greeting extends Application{
String sayHello(){
return "Hello!";
}
}
我的主要活动:
package com.ma.singhalja.testclass;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
greeting Hello = new greeting();
Hello.sayHello();
System.out.println(Hello);
}
}
日志: I / System.out:com.ma.singhalja.testclass.greeting@99e92d
任何人都可以告诉我们如何实际获得String" Hello"进入对象?我已经尝试使用.toString()转换为String。
谢谢!
答案 0 :(得分:1)
从技术上讲,你不打印好东西:
System.out.println(Hello.sayHello());
这会输出System.out.println(...)
Hello.sayHello()
的结果Hello!
,System.out.println(Hello);
。
如果您执行Class
,则表示您正在尝试打印Greeting
。
顺便说一下:
greeting
而不是Application
getApplication()
在Android中效果不佳。这是平台
那。使用System.out.println(...)
Log.d(...)
这不是Android-thing ...你可以使用
SELECT tp.d_id , u.email , ta.email_subject AS headline , ta.start_date , ta.closing_date , tp.call_cost , SUM(tpc.duration) AS duration , COUNT(tpc.id) AS call_count , ta.currency
, ( SELECT MIN(hr) KEEP ( DENSE_RANK LAST ORDER BY cnt, max_duration, l_id ) AS most_pop_call_start FROM (
SELECT EXTRACT(HOUR FROM started) AS hr, count(*) AS cnt , SUM(duration) AS duration , MAX(duration) AS max_duration , phone_number_id AS l_id FROM table_phone_call GROUP BY EXTRACT(HOUR FROM started), phone_number_id
) where l_id = tpc.phone_number_id
) AS most_pop_call_start
--, STATS_MODE(extract(HOUR from tpc.started)) AS most_pop_call_start
, AVG(tpc.duration) AS avg_duration
, tb.name AS business_name
FROM table_a ta
JOIN table_phone tp ON ta.id = tp.d_id
JOIN table_phone_call tpc ON tp.phone_id = tpc.phone_number_id
JOIN table_b tb ON ta.business_id = tb.id
JOIN users u ON tb.id = u.business_id
WHERE phone_id IS NOT NULL
AND TRUNC(ta.closing_date) = to_date('#{jobParameters['dateCriteria']}', 'dd-mm-yyyy')
GROUP BY tp.d_id , ta.email_subject , ta.start_date , ta.closing_date , tp.call_cost , tpc.phone_number_id , u.email , ta.currency , tb.name
用于调试