object

Java课程设计--个人总结

最后都变了- 提交于 2020-01-09 03:48:00
Java课程设计--个人总结 Java团队课程设计-socket聊天室(Day4总结篇) 个人负责模块和任务说明 user端的发送到server的代码 user端接收server发送的代码 储存消息记录的数据结构 参与server端的代码编写 负责整个系统的具体转发逻辑和接收逻辑 Gitee提交记录 部分提交记录 各个分支对master分支的影响 详细个人提交记录 任务负责详细说明 我将转发信息分为三种情况: 1.当用户上线后系统马上发送的用户下线后别人发给他的离线消息 class OfflineMessage 2.当用户在线时别人发送给他的在线消息 class OnlineMessage 3.用户向服务器请求的历史消息 class HistoryMessage 因为其中的成员都是一样的,所以他们继承于class Message,具体关于如下方UML类图显示 既然要用socket发送,那么就需要implements Serializable,使其序列化 客户端具体发送--接收模型 先附上UML类图 其中class UserController中的方法和成员 public class UserController 在这个类里用于发送各种信息,比如登录请求、注册请求、历史信息请求、发送信息、发送文件 登录请求: public static void requestLogin(User

集合框架

依然范特西╮ 提交于 2020-01-09 03:15:58
之前我们学到了数组,为我们批量处理数据提供了便利,但是数组的长度不可变,在实际的生活中,我们处理的数据大小都是未知的,可变的。所以就引入了集合。 集合存储的数据类型可以不同,长度可变,空间也不固定,用于储存,检索和传输对象。不能保存基础数据类型的数据,比如int,只能装箱变为Integer类型。 一:最高级别Collection接口(单列数据) 1.List接口是Collection的子接口,List集合是有序集合,集合中的元素可以重复,访问集合中的元素可以根据元素的索引来访问。 1.1.ArrayList类是接口List的实现类,在我们处理集合时,增删不频繁时使用,查询多的时候使用。 1.2.LinkedList类也是接口List的实现类。增删多的时候使用。因为它内部双向循环列表,所以查询时也比较费时。 2.Set接口是Collection的子接口,Set集合是无序集合,集合中的元素不可以重复,访问集合中的元素只能根据元素本身来访问(也是不能集合里元素不允许重复的原因)。 2.1.HashSet元素自动排序,不可有重复的内容。 二:最高级别Map 1,HashMap实现了Map接口,继承AbstractMap 三:下面是一些集合的基础操作代码(ArrayList) public static void main(String[] args) { List li=new

How many objects are created due to inheritance in java?

做~自己de王妃 提交于 2020-01-09 02:57:05
问题 Let's say I have three classes: class A { A() { // super(); System.out.println("class A"); } } class B extends A { B() { // super(); System.out.println("class B"); } } class C extends B { public static void main(String args[]) { C c = new C(); //Parent constructor will get called } } When I create an instance of class C, it calls the constructor of super class. So, is there more than one object that is getting created? If only one object is created, then how is super() like another class'

JS: Does Object.assign() create deep copy or shallow copy

强颜欢笑 提交于 2020-01-09 02:13:48
问题 I just came across this concept of var copy = Object.assign({}, originalObject); which creates a copy of original object into the " copy " object. However, my question is, does this way of cloning object create a deep copy or a shallow copy? PS: The confusion is, if it creates a deep copy, then it would be the easiest way to clone an object. 回答1: Forget about deep copy, even shallow copy isn't safe, if the object you're copying has a property with enumerable attribute set to false. MDN : The

python语言之正则

喜夏-厌秋 提交于 2020-01-08 23:59:45
目录 (一)正则表达式的构成 (三)Python正则模块之MatchObject (一)正则表达式的构成 正则表达式由两种元素组成: 字面值 普通字符和 需要转义的字符(,^,$,.,|,?,*,+,(),[],{}) 元字符(特殊意思) .:除\n外的所有字符 \d:数字,等同于[0-9] \D:匹配所有非数字 [ ^ 0-9] \s:空白字符,\t\r\n\f\v \S:非空白字符[ ^\t\r\n\f\v] \w:字母数字字符[A-Za-z0-9_] \W:字母数字字符[ ^A-Za-z0-9_] |:yes|no +:一次或者多次 ?:一次或者0次 *:0次或者多次 {3,5}:3次到5次 {m}:m次 {m,}:最少m次 {,n}:最多n次 贪婪与非贪婪 非贪婪(两次后加?) .*? 贪婪(默认) 边界匹配 ^:行首 $:行尾 \b:单词边界 \B:非单词边界 \A:输入开头 \Z:输入结尾 ​ ​ (二)Python正则模块之RegexObject 模块:import re RegexObject:编译后的正则表达式对象(编译为字节码并缓存re.compile),有利于重用 findAll方法 import re text = "Tom is 8 years old. Mike is 23 years old" pattern = re.compile('\d+')

java泛型中的各种限制

一个人想着一个人 提交于 2020-01-08 21:01:33
java和其他语言一样,都支持泛型,包括泛型类和泛型方法,但是java的泛型比较特殊。因为java的泛型并不是在java诞生之初就加入的,在很长的一段时间里,java是没有泛型的,在需要泛型的地方,统统都采用协变的方式,也就是采用Object,比如ArrayList类,元素的类型就是Object。为了兼容原来的代码,java的设计者希望在加入泛型之后,所有的泛型都可以传给原来的对应的非泛型参数,例如,可以把ArrayList<xxx>传给原来接收ArrayList参数的方法。为了达到这个目的,java的设计者采取了一种叫做“类型擦除”的实现方式,把泛型拦截在了编译阶段,在虚拟机中,所有的泛型参数最终的类型都会是转换后的Object类型(如果有类型限定,则是限定后的类型,如 <T extends Super>,则泛型T在虚拟机中统一都是Super类型),然后利用协变性而兼容所有类型或限定类型参数的传入,从而实现泛型。 比如用户定义泛型类: class Super<T,V>{ T a; public V mehod(T arv){ a=arv; return a; } } 在经过编译阶段的类型擦除之后,虚拟机看到的Super类是这样的: class Super{ Object a; public Object mehod(Object arv){ a=arv; return a; }

JavaScript: empty array, [ ] evaluates to true in conditional structures. Why is this?

我只是一个虾纸丫 提交于 2020-01-08 19:41:43
问题 I was encountering a lot of bugs in my code because I expected this expression: Boolean([]); to evaluate to false. But this wasn't the case as it evaluated to true. Therefore, functions that possibly returned [] like this: // Where myCollection possibly returned [ obj1, obj2, obj3] or [] if(myCollection) { // ... }else { // ... } did not do expected things. Am I mistaken in assuming that [] an empty array? Also, Is this behavior consistent in all browsers? Or are there any gotchas there too?

JavaScript: empty array, [ ] evaluates to true in conditional structures. Why is this?

纵饮孤独 提交于 2020-01-08 19:40:50
问题 I was encountering a lot of bugs in my code because I expected this expression: Boolean([]); to evaluate to false. But this wasn't the case as it evaluated to true. Therefore, functions that possibly returned [] like this: // Where myCollection possibly returned [ obj1, obj2, obj3] or [] if(myCollection) { // ... }else { // ... } did not do expected things. Am I mistaken in assuming that [] an empty array? Also, Is this behavior consistent in all browsers? Or are there any gotchas there too?

Java反射机制

☆樱花仙子☆ 提交于 2020-01-08 18:33:45
所谓反射,就是能够让运行于JVM中的程序检测和修改运行时的行为。 而Class反射对象描述类语义结构,可以从Class对象中获取构造函数、成员变量、方法类等类元素的反射对象,并以编程的方式通过这些反射对象对目标类对象进行操作。这些反射对象类在java.reflect包中定义。 主要的反射类 Constructor 类的构造函数反射类,会通过Class#getConstructor()方法获取类的构造函数反射对象;Constructor类的主要方法是newInstance(Object[] initargs),通过这个方法可以创建一个类的实例。 Method 类方法的反射类,通过Class#getDeclaredMethods()方法获取类的所有方法反射类对象的数组,或者是通过getDeclaredMethods(String name)来获取特定方法的反射类对象。Method类的一个主要方法是invoke(Object obj,Object[] args),其中obj是操作的目标对象,args是方法的入参,通过这个方法可以获取到具体实例对象的具体方法。 Filed 类的成员变量的反射类,通过Class#getDeclaredFieldsO方法可以获取类的成员变量反射对象数组,通过Class#getDeclaredField(String name

js判断数据类型

喜你入骨 提交于 2020-01-08 13:43:26
ECMAScript 中的数据类型   6种简单数据类型:Undefined, Null, Number, String, Boolean, Symbol   1种复杂数据类型(其中又可以分为几类):Object, Array, Date, RegExp, Function, 自定义类型 判断数据类型   1.typeof   typeof是检测简单数据类型的最好选择。     var bool = true     var num = 1     var str = 'a'     var und = undefined     var nul = null     var arr = [1,2,3]     var obj = {}    var dat = new Date()     var fun = function(){}     var reg = new RegExp()     console.log(typeof bool); //boolean     console.log(typeof num); //number     console.log(typeof str); //string     console.log(typeof und); //undefined     console.log(typeof nul); //object