[Java in NetBeans] Lesson 03. More Variables / Type Casting
2018-10-25 06:11 Johnson_强生仔仔 阅读(187) 评论(0) 编辑 收藏 举报这个课程的参考视频在youtube。
主要学到的知识点有:
- It is different from python, that "1" only present string "1", and '1' only presents char '1'.
- (type) can chang the type , e.g. (int) (totalScore/4.5); will change the result of(totoalScore/4.5) which is a float into integer.
- But if want to change String to int or double, it does not work for previous method. Need Integer.parseInt("3") change "3" as 3, need Double.parseDouble("3.0") change "3.0" into 3.0.
- x = 2, y = 3; if we want to get double 2/3, then we can do result = x/ (float) y;