摘要: 1 public static void main(String[] args){ 2 3 int sum = 1000000; 4 long start = System.currentTimeMillis(); 5 for (int i = 0; i < sum; i++) { 6 String 阅读全文
posted @ 2022-08-01 23:41 再努力一些 阅读(26) 评论(0) 推荐(0)
摘要: 面向对象 对象:属性、方法。 table,function。 student = {name = "张三",age = 18, gotoSchool = function(name) print(name.."上学") end} --[[ student.gotoSchool = function( 阅读全文
posted @ 2022-07-26 20:39 再努力一些 阅读(27) 评论(0) 推荐(0)
摘要: 对表进行更新时调用。 函数用法 print(" newindex ") mytab2 = {"a","b"} metatab2 = { __newindex=function(tab,key,value) print("被调用") rawset(tab,key,value) end } setmet 阅读全文
posted @ 2022-07-25 23:45 再努力一些 阅读(32) 评论(0) 推荐(0)
摘要: __index(两个下划线) 定义普通表 给普通表p,设置元表y,而元表y中有index,__index有一个表i,i中有我们访问的不存在的key. __index=表 print(" 测试__index ") -- 普通表 tab1 = {"a","b","c"} print(tab1[5]) - 阅读全文
posted @ 2022-07-25 22:49 再努力一些 阅读(55) 评论(0) 推荐(0)
摘要: 允许我们改变table的行为 setmetatable(普通表,元表) 返回普通表 getmetatable() 获取元表 -- a = {"a","b","c"} -- b = {} -- c = setmetatable(a,b) print(" ") f = {} print("f:",f) 阅读全文
posted @ 2022-07-25 22:30 再努力一些 阅读(97) 评论(0) 推荐(0)
摘要: require("模块名") require "模块名" -- 调用模块 require("module") print(module.constant) module.func3() 阅读全文
posted @ 2022-07-25 20:30 再努力一些 阅读(31) 评论(0) 推荐(0)
摘要: 报错内容 .\module.lua:10: '(' expected near '.' stack traceback: [C]: ? [C]: in function 'require' .\testModule.lua:2: in main chunk [C]: ? error:在定义私有的函数 阅读全文
posted @ 2022-07-25 20:24 再努力一些 阅读(717) 评论(0) 推荐(0)
摘要: -- 模块:module.lua module = {} module.constant="模块中的变量" function module.func1() print("这是函数1") end local function func2() print("这是私有函数2") end function 阅读全文
posted @ 2022-07-25 20:09 再努力一些 阅读(48) 评论(0) 推荐(0)
摘要: 1.String类是不可变类,即一旦一个String对象被创建后,包含在这个对象中的字符序列是不可改变的额,直至这个对象销毁。 2.StringBuffer类则代表一个字符序列的字符串,可以通过append、iusert、reverse、setChartAt、setLength等方法改变其内容。一旦 阅读全文
posted @ 2021-08-18 17:35 再努力一些 阅读(65) 评论(0) 推荐(0)
摘要: 总结: throw和throws的区别: (1)位置不同: throw:方法内部 throws:方法的签名处,方法的声明处 (2)内容不同: throw+异常对象(检查异常,运行时异常) throws+异常的类型(可以多个类型,用,拼接) (3)作用不同: throw:异常出现的源头,制造异常。 t 阅读全文
posted @ 2021-08-16 21:50 再努力一些 阅读(469) 评论(0) 推荐(0)