使用Netty的ChannelLocal(Usage of Netty's ChannelLocal)
用于Netty的JavaDocs解释ChannelLocal与ThreadLocal类似,但是我对它的使用有一些疑问。 ThreadLocal是一个静态类,具有访问特定于实例的对象的静态方法。 ChannelLocal不是静态的,具有静态内部映射或具有静态方法。 该文档不包括访问ChannelLocal或将对象放入ChannelLocal的示例,因此我希望有人可以让我对它的用法有所了解。
谢谢!
The JavaDocs for Netty explain ChannelLocal to be similar to ThreadLocal, however I've got some questions about it's usage. ThreadLocal is a static class with static methods that access instance-specific objects. ChannelLocal is not static, have a static internal map or have static methods. The documentation doesn't include an example of accessing ChannelLocal or placing an object into ChannelLocal, so I was hoping someone could give me some insight into it's usage.
Thanks!
原文:https://stackoverflow.com/questions/8449663
最满意答案
程序输出一堆空值,因为你正在创建
studentAges
和studentNames
,但是你没有把东西放进去。@PawełAdamski的回答是不正确的
if(occupations[i].equalsIgnoreCase("student")); studentCount++;
意味着你总是在增加
studentCount
。我建议你使用一些内部类,而不是使用
Arrays.sort()
进行排序(你必须实现Comparable接口或实现Comparator接口进行排序)。Program outputs bunch of nulls because you are creating
studentAges
andstudentNames
, but you are not putting something into it.@Paweł Adamski's answer is incorrect
if(occupations[i].equalsIgnoreCase("student")); studentCount++;
means that you are increasing
studentCount
always.I would recommend you to use some inner class and than use
Arrays.sort()
for sorting (You have to implement Comparable interface or implements Comparator interface for sorting).
相关问答
更多-
要切入追逐,这里的问题在于如何分配tempData。 StringReturn* ret = stringReturnInfo(); StringArg *str; str = stringArg(0); int lengths = str->length; char *datas = str->data; string tempData = datas; StringArg不存储以NUL结尾的字符串,而是提供长度并期望您自己管理。 select a.val1, ADMIN.D ...
-
将您的最后一行更改为: NewString = list.toArray(new String[list.size()]); toArray(..)方法将其尝试填充列表数据的列表作为参数。 您正在传递一个长度为3的列表,因此最后一个元素保持为空。 根据我的建议,您可以使用列表的新大小创建一个新阵列。 作为一个旁注:我建议你重新审视你的命名约定。 根据建议的命名约定,您的方法和变量名称应以小写字母开头 更新:但你最好使用Arrays.copyOfRange(..)正如其他人所建议的那样。 Change yo ...
-
您可以使用单个数组减少数组。 这也适用于多个阵列。 var inputArray1 = ['abc', 'def', 'ghi'], inputArray2 = ['3', '6', '9'], outputArray = [inputArray1, inputArray2].reduce((a, b) => a.map((v, i) => v + ' - ' + b[i])); console.log(outputArray); 更实用 var inputArray1 = ['a ...
-
在第二组代码中,正在调用takeInGridNums(..)方法,但是您正在创建一个tempSizeFull大的网格。 但是,你的tempSizeFill变量为0,因为你将它基于main中的userGridSize并初始化为0.当用户输入他们想要的网格大小时, tempSizeFull不会自动更新,所以你的for循环正在跳过。 所以代替: userGridSize = scanner.nextInt(); tempMultiply = userGridSize * userGridSize; System. ...
-
由于这一行: void Card(){..} 删除void 。 此代码表示方法(构造函数不描述返回类型 - 即使是void )。 所以编译器添加了默认的无参数构造函数,它用null初始化cardValue 。 because of this line: void Card(){..} remove void. This code represent method (constructors doesn't describe return type - even with void). So compil ...
-
我在阅读了roliu帖子的链接后设法解决了这个问题。 char **commands[ NUM_COMMANDS ]; char *command1[] = {"command1", 0}; char *command2[] = {"command2", "arg", 0}; argv[0] = "grep"; commands[0] = (char **) command1; commands[1] = (char **) argv; commands[2] = (char **) command2; ...
-
你的制定者是错误的: // userLastname is the parameter you are passing in. lastname is the class // variable. You are setting the parameter to the value of the uninitialized // value of lastname. userLastname then is thrown away the setter function ends. userLast ...
-
程序输出一堆空值,因为你正在创建studentAges和studentNames ,但是你没有把东西放进去。 @PawełAdamski的回答是不正确的 if(occupations[i].equalsIgnoreCase("student")); studentCount++; 意味着你总是在增加studentCount 。 我建议你使用一些内部类,而不是使用Arrays.sort()进行排序(你必须实现Comparable接口或实现Comparator接口进行排序)。 Program outputs ...
-
NULL数组上的Cartesian(Cartesian on NULL arrays)[2023-12-17]
由于Eric的方法是使用IEnumerable> ,你必须做这样的事情: 埃里克的代码: static IEnumerable > CartesianProduct (this IEnumerable > sequences) { IEnumerable > emptyProduct = new[] { Enumerable.Empty () }; return seque ... -
比较字符串数组(Comparing string arrays)[2024-03-04]
因为下面的行检查单词只转换第一个数组的小写字符串而不是第二个字符串。 它只获得匹配的值,如m-> m,包括重复。 [[n lowercaseString] compare:w] == NSEqualToComparison 以下是我的问题训练。 NSMutableArray *actualarray1=[[NSMutableArray alloc] init]; NSMutableArray *actualarray2=[[NSMutableArray alloc] init]; actualarray1 ...