一个局部内部类可以访问非final的外部对象?
 class Outer1
{
    int x=100;
    void method(int a)
    {
        int y=4;
        class Inner    
        {

             void function()
            {
                System.out.println(y);  
            }

        }
        new Inner().function();   
    }

}




public class InnerDemo2 
{
    public static void main(String[]args)
    {
        new Outer1().method(7);

    }

}

看公开课上说,局部内部类只能访问final的变量,为什么我可以,是JDK版本不同的原因吗?还是什么?

1个回答

图片说明

用你的代码测试,确实会报错,我的jdk是1.8的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
局部内部类访问外部类的局部变量
在书上看到这样一段话:如果局部内部类要访问外部类的局部变量,则此变量必须是final修饰的,否则不能访问。说是为了提高局部变量的生命周期,可不可以说的通俗一些?
局部内部类 只能访问方法中final类型的变量吗,为什么?
这是书中说的: 局部内部类(Local Inner Class):定义在方法当中,只能访问方法中声明的final类型的变量 但是:我下面的练习发现:它也可以访问非final类型的变量: 这是为什么呢?还是Jdk7版本后新增加的特性? // 3.局部内部类 // 访问权限:可以访问外部内的静态或非静态属性和方法: class LocalInner { public void doSomething() { String b = "1"; final int a = 4; class Inner3 { int c = 1; public void test() { System.out.println(a + b);//b不是final,却可以发访问 } } // 只能在方法块中实例 Inner3 li1 = new Inner3(); li1.test(); System.out.println(li1.c); } }
Java匿名内部类访问外部类的局部变量
Java匿名内部类访问外部类的局部变量,那么这个局部变量需要用final修饰吗? 为什么我的测试没有用final却可以?
为什么局部内部类所用的变量要用final修饰
为什么局部内部类所用的变量要用final修饰,网上有很多说法,有说内部类,与局部变量生命周期的,
为什么外部类能访问内部类的私有成员?
在学习单例时发现,外部类可以访问内部类的私有成员 如下面代码所示: //Initialization on Demand Holder class Singleton { private Singleton() { } private static class HolderClass { private final static Singleton instance = new Singleton(); } public static Singleton getInstance() { return HolderClass.instance; } public static void main(String args[]) { Singleton s1, s2; s1 = Singleton.getInstance(); s2 = Singleton.getInstance(); System.out.println(s1==s2); } } 内部类能访问外部类成员比较好理解,但为什么外部类能访问内部类的私有成员呢?
内部类传值给外部类时为什么可以用对象数组来存放要传的值呢?
比如说下列代码 方法1 – 对象数组法通过一个final的Object对象数组,存放需要的值 public long countUser(final String userType) { final Object[] objs = new Object[1]; Trans.run(new Atom(){ public void run() { objs[0] = dao.count(User.class, Cnd.where('userType', '=', userType)); } }); return ((Number)objs[0]).longValue(); } 为什么不能直接返回final以后的对象值呢?为什么一定要放在数组里才可以取得到呢?
Java匿名类可以引用非final变量了?
public class Test1 { public FilenameFilter filter(final String regex) { //匿名类,直接用匿名类来返回一个FilenameFilter类的对象 return new FilenameFilter() { //对正则表达式进行编译 private Pattern pattern = Pattern.compile(regex); //覆写FilenameFilter接口中的唯一的accept方法 @Override public boolean accept(File dir, String name) { return pattern.matcher(name).matches(); } }; } } 上面的类中,把方法的形参final String regex改成String regex照样编译通过,请问是为什么?不是说匿名类和局部类只能引用final变量吗? 环境是jdk1.8,IDE是Intellij IDEA CE
java方法中定义的局部内部类问题
在方法中定义的内部类为什么只能访问方法中的final类型局部变量? package com.study; interface OutInterface2{ //定义一个接口 } class OuterClass3 { public OutInterface2 doit(final String x){//doit方法参数为final类型 //在doit()方法中定义一个内部类 class InnerClass2 implements OutInterface2{ InnerClass2(String s){ s=x; System.out.println(s); } } return new InnerClass2("doit"); } } 其中s=x是什么意思?最后一句是return new InnerClass("doit"),这个“doit”参数传递给InnerClass的构造方法有意义吗? System.out.println(s)不会输出doit,而会输出X的内容?
请问在Java中,final关键词在实际开发中具体有什么作用和意义?
![图片说明](https://img-ask.csdn.net/upload/202002/16/1581856950_886510.png) 如图中红框,这两个成员变量用final关键词修饰后有什么作用和意义?百度查了说final修饰的变量不能被修改,final修饰的变量必须显示初始化。 实在是搞不懂不能修改和必须显示初始化到底有什么好处,求教大牛解答,万分感谢!
final方法和静态方法在元空间中的存储位置
想要请教一下各位大大 类的非final和非静态方法都存储在instanceKlass对象的虚方法表中,那么这些final方法和静态方法存储在instanceKlass哪个位置呢? ![图片说明](https://img-ask.csdn.net/upload/201912/27/1577429201_138857.png)
如何@autowired注入一个带有final属性的bean
@Service public class Demo1Impl { private final String name; Demo1Impl(String name) { this.name = name; } public String getName(int i) { return "name"; } } 单元测试要测试这个getName方法 @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = DemoApplication.class) class Demo1ImplTest { @Autowired Demo1Impl demo1; @Test void getName() { System.out.println(demo1.getName(1)); } } run后报错,显示找不到合格的bean,这是一个Springboot项目,单元测试的时候我该如何注入Demo1Impl呢?
自己搭建的tomcat服务器的url怎么写
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; public class HttpServer { private static final Integer port = 80;//HTTP默认端口80 public static void main(String[] args) { ServerSocket serverSocket; try { //建立服务器Socket,监听客户端请求 serverSocket = new ServerSocket(port); System.out.println("服务器端口:"+serverSocket.getLocalPort()); //死循环不间断监听客户端请求 while(true){ final Socket socket = serverSocket.accept(); System.out.println("接收到一个请求,请求地址:"+ socket.getInetAddress()+":"+socket.getPort()); //并发处理HTTP客户端请求 service(socket); } } catch (IOException e) { e.printStackTrace(); } } public static void service(final Socket socket) { new Thread(){ public void run(){ InputStream inSocket; try { //获取HTTP请求头 inSocket = socket.getInputStream(); int size = inSocket.available(); byte[] buffer = new byte[size]; inSocket.read(buffer); String request = new String(buffer); System.out.println("ClientBrowser:\n"+request+"\n" + "------------------------------------------------------------------"); String firstLineOfRequest = ""; //http报文头 String[] heads; //报文头的数据集合 String uri = "/index.html"; String contentType =""; if(request.length() > 0){ firstLineOfRequest = request.substring(0,request.indexOf("\r\n")); heads = firstLineOfRequest.split(" "); uri = heads[1]; if(uri.indexOf("html") != -1){ contentType = "text/html"; }else{ contentType = "application/octet-stream"; } } System.out.println("http报文内容:"+request.substring(request.indexOf("\r\n"),request.length())); //将响应头发送给客户端 String responseFirstLine = "HTTP/1.1 200 OK\r\n"; String responseHead = "Content-Type:" + contentType +"\r\n"; OutputStream outSocket = socket.getOutputStream(); System.out.println("ServerResponse:\n"+responseFirstLine+"\n"+responseHead+"\n" + "--------------------------------------------------------------------"); outSocket.write(responseFirstLine.getBytes()); outSocket.write(responseHead.getBytes()); //通过HTTP请求中的uri读取相应文件发送给客户端 FileInputStream writehtml = new FileInputStream(new File("wwwroot"+uri)); outSocket.write("\r\n".getBytes()); byte[] htmlbuffer = new byte[writehtml.available()]; if(writehtml !=null){ int len = 0; System.out.println("writeHtml"); while((len = writehtml.read(htmlbuffer)) != -1){ outSocket.write(htmlbuffer, 0,len); } } outSocket.close(); socket.close(); } catch (IOException e) { e.printStackTrace(); } } }.start(); } } ``` ```
lstm加三层感知器的神经网络,预测行人坐标轨迹,loss不下降是怎么原因?
我用两层的lstm编码坐标,然后用三层感知器解码,预测后五帧的轨迹,用的是mse和adam,尝试了从0.00001到0.3的学习率,batch size也改过train loss一直在小幅度的波动,test loss一直不变,想请问出现这种情况是可能是什么原因? ``` import torch import torch.nn as nn import torch.utils.data as data import numpy as np import random from torch import optim from helper import AverageMeter, adjust_learning_rate class net(torch.nn.Module): def __init__(self): super(net, self).__init__() self.gru = nn.GRU(2, 128, 2) self.lstm = nn.LSTM(2, 128, 2) def forward(self, input1, hidden): next_h_list = [] out_list = [] for i in range(20): input_tr = input1[:,i,:].unsqueeze(0) output, next_h = self.lstm(input_tr, (hidden[i][0] , hidden[i][1])) next_h_list.append(next_h) out_list.append(output.squeeze(0)) output_tr = torch.stack(out_list, 1) return output_tr, next_h_list def init_hidden(self, batch_size): return [[torch.zeros(2, batch_size, 128, requires_grad=True).cuda() for _ in range(2)] for _ in range(20)] #这里的维度(2,5,128)是从外向内的,最里面是128维 class decoder(torch.nn.Module): def __init__(self): super(decoder, self).__init__() self.fc1 = torch.nn.Linear(128 , 2) def forward(self, input): de_list = [] for i in range(20): output = self.fc1(input[:,i,:]) de_list.append(output) out = torch.stack(de_list, 1) return out class Model: def init(self): self.lr = 0.1 self.weight_decay = 5e-3 self.n_epochs = 500 self.loss_list = [] self.time_window = 300 self.window_size = 1000 self.m1 = net().cuda() self.m2 = decoder().cuda() self.m1_optim = optim.Adam(self.m1.parameters(), lr = self.lr, weight_decay = self.weight_decay) self.m2_optim = optim.Adam(self.m1.parameters(), lr = self.lr, weight_decay = self.weight_decay) self.batch_size = 256 self.test_times = 5 self.dataload('data/GC.npz') def dataload(self, path): data = np.load(path) tr_X, tr_Y = data['train_X'], data['train_Y'] te_X, te_Y = data['test_X'], data['test_Y'] tr_input = torch.FloatTensor(tr_X) tr_target = torch.FloatTensor(tr_Y) self.tr_input = tr_input.cuda() self.tr_target = tr_target.cuda() self.te_input = torch.FloatTensor(te_X).cuda() self.te_target = torch.FloatTensor(te_Y).cuda() # data loader train = torch.utils.data.TensorDataset(tr_input, tr_target) self.train_loader = torch.utils.data.DataLoader(train, batch_size=self.batch_size, shuffle=True, num_workers=4) def run(self, tr_input, tr_target): batch_size = tr_input.size(0) encoder_hidden = self.m1.init_hidden(batch_size) #print('batch_size: ',batch_size) tr_final = tr_input[:,:,4] #选择第五帧 for i in range(4): output , hidden = self.m1(tr_input[:,:,i], encoder_hidden) re_list = [] for i in range(5): output , hidden = self.m1(tr_final, encoder_hidden) output_decoder = self.m2(output) tr_final = output_decoder re_list.append(output_decoder) predict = torch.stack(re_list, 2) #loss L2_loss = ((tr_target - predict) **2).sum() / 20 MSE_loss = ((tr_target - predict) **2).sum(3).sqrt().mean() self.loss = L2_loss return predict, L2_loss.item(), MSE_loss.item() def train(self, epoch): MSE_loss_meter = AverageMeter() L2_square_loss_meter = AverageMeter() adjust_learning_rate([self.m1_optim, self.m2_optim], self.lr, epoch) for i ,(tr_input, tr_target)in enumerate(self.train_loader): tr_input = tr_input.cuda() tr_target = tr_target.cuda() self.m1_optim.zero_grad() self.m2_optim.zero_grad() predict, L2_loss, MSE_loss = self.run(tr_input, tr_target) MSE_loss_meter.update(MSE_loss) L2_square_loss_meter.update(L2_loss) self.loss.backward() self.m1_optim.step() self.m2_optim.step() return MSE_loss_meter.avg, L2_square_loss_meter.avg def test(self): with torch.no_grad(): predi, L2_square_lo, MSE_lo = self.run(self.te_input, self.te_target) return MSE_lo, L2_square_lo def final(self, epoch): self.init() for i in range(1, epoch + 1): MSE_loss, L2_square_loss = self.train(epoch) print('----------------epoch------------------: ',i+1) print('mse: ', MSE_loss) print('l2: ', L2_square_loss) self.loss_list.append(MSE_loss) if i % self.test_times == 0: test_loss_MSE , test_loss_L2 = self.test() print('----TEST----\n' + 'MSE Loss:%s' % test_loss_MSE) print('----TEST----\n' + 'L2 Loss:%s' % test_loss_L2) def set_random_seed(random_seed=0): np.random.seed(random_seed) torch.manual_seed(random_seed) torch.cuda.manual_seed_all(random_seed) random.seed(random_seed) def main(): set_random_seed() M = Model() M.final(1000) if __name__ == '__main__': main() ```
Line & Circle Maze 迷宫的问题
Problem Description A deranged algorithms professor has devised a terrible final exam: he throws his students into a strange maze formed entirely of linear and circular paths, with line segment endpoints and object intersections forming the junctions of the maze. The professor gives his students a map of the maze and a fixed amount of time to find the exit before he floods the maze with xerobiton particles, causing anyone still in the maze to be immediately inverted at the quantum level. Students who escape pass the course; those who don't are trapped forever in a parallel universe where the grass is blue and the sky is green. The entrance and the exit are always at a junction as defined above. Knowing that clever ACM programming students will always follow the shortest possible path between two junctions, he chooses the entrance and exit junctions so that the distance that they have to travel is as far as possible. That is, he examines all pairs of junctions that have a path between them, and selects a pair of junctions whose shortest path distance is the longest possible for the maze (which he rebuilds every semester, of course, as the motivation to cheat on this exam is very high). The joy he derives from quantumly inverting the majority of his students is marred by the tedium of computing the length of the longest of the shortest paths (he needs this to know to decide how much time to put on the clock), so he wants you to write a program to do it for him. He already has a program that generates the mazes, essentially just a random collection of line segments and circles. Your job is to take that collection of line segments and circles, determine the shortest paths between all the distinct pairs of junctions, and report the length of the longest one. The input to your program is the output of the program that generates his mazes. That program was written by another student, much like yourself, and it meets a few of the professor's specifications: 1) No endpoint of a line segment will lie on a circle; 2)No line segment will intersect a circle at a tangent; 3) If two circles intersect, they intersect at exactly two distinct points; 4)Every maze contains at least two junctions; that is, a minimum maze is either a single line segment, or two circles that intersect. There is, however, one bug in the program. (He would like to have it fixed, but unfortunately the student who wrote the code never gave him the source, and is now forever trapped in a parallel universe.) That bug is that the maze is not always entirely connected. There might be line segments or circles, or both, off by themselves that intersect nothing, or even little "submazes" composed of intersecting line segments and circles that as a whole are not connected to the rest of the maze. The professor insists that your solution account for this! The length that you report must be for a path between connected junctions! Example: 1.2. 3.4. Detail Description: Pictrue 1: Line segments only. The large dots are the junction pair whose shortest path is the longest possible. Pictrue 2: An example using circles only. Note that in this case there is also another pair of junctions with the same length longest possible shortest path. Pictrue 3: Disconnected components. Pictrue 4: Now the line segments are connected by a circle, allowing for a longer shortest path. Input An input test case is a collection of line segments and circles. A line segment is specified as "L X1 Y1 X2 Y2" where "L" is a literal character, and (X1,Y1) and (X2,Y2) are the line segment endpoints. A circle is specified by "C X Y R" where "C" is a literal character, (X,Y) is the center of the circle, and R is its radius. All input values are integers, and line segment and circle objects are entirely contained in the first quadrant within the box defined by (0,0) at the lower left and (100,100) at the upper right. Each test case will consist of from 1 to 20 objects, terminated by a line containing only a single asterisk. Following the final test case, a line containing only a single asterisk marks the end of the input. Output For each input maze, output "Case N: ", where N is the input case number starting at one (1), followed by the length, rounded to one decimal, of the longest possible shortest path between a pair of connected junctions. Sample Input L 10 0 50 40 L 10 4 0 50 0 L 10 1 0 60 1 0 L 0 30 50 30 * C 25 2 5 25 C 50 2 5 25 C 25 5 0 25 C 50 5 0 25 * L 0 0 80 80 L 80 1 00 100 80 * L 0 0 80 80 L 80 1 00 100 80 C 85 8 5 10 * * Sample Output Ca se 1: 68.3 Ca se 2: 78.5 Ca se 3: 113.1 Ca se 4: 140.8
为什么HandlerExcutionChain类中的属性有一个拦截器的数组和一个拦截器的集合,有什么道理?
public class HandlerExecutionChain { private static final Log logger = LogFactory.getLog(HandlerExecutionChain.class); private final Object handler; private HandlerInterceptor[] interceptors; private List<HandlerInterceptor> interceptorList; private int interceptorIndex = -1; HandlerExecutionChain的属性为什么有一个拦截器的数组还有一个拦截器的集合,作用是啥,虽然这个类中的方法里有数组与集合的相互转换,但是实在不明白为什么设置一个数组又设置一个集合?求大神告知!
Navy maneuvers 的问题
Problem Description In times of peace, various countries have held regular maneuvers to maintain military’s vigilance. There is a navy fleet in a certain country which also starts a new round imaginary naval battle. At the maneuver stage, the admiral intends to assess the combat effectiveness of two warships, “Victory” and “Glory”, so he lets two warships carry out countering exercises. Both of the warship commanders are young and promising, who graduated from naval academy as outstanding students. Not only have they had rich navigation direction experiences, but also have profound scientific knowledge, especially in mathematics. The admiral appoints one marine area dotted with many islets. Suppose all these islets are occupied by the enemy, and there are positive integers of enemy firebases. The hypothetical exercise situations given by the admiral and the rule of the competition are as follows: (1) All the occupied islets are connected. There are some routes among these islets, but the route from one islet to another islet is unidirectional. In other words, if we take an islet as a node and an islet route as an edge, then we will get a directed non-cyclic connected graph. (2) There is a unique 1st islet in the graph. If we start from this islet, we can reach any other islet. (maybe the 1st islet is not the islet which is numbered 1) (3) At the beginning of the maneuver, two warships simultaneously sail to the 1st islets and eliminate all enemy firebases together. (4) The two warships, “Victory” and “Glory” take turns to navigate and exchange as soon as they arrive at an islet, then they move forward together. But each time they can only go along the unidirectional route, sail to the islet directly connected to the current, and eliminates all the enemy firebases on the islet. By the way, when start from 1st islet, “Victory” first navigates. (5) Because each route is unidirectional, and graph is non-cycle, therefore the maneuver terminates when the two warships fail to go on navigating. (6)When the maneuver ends, sum the numbers of eliminated enemy firebases on the routing path. If the number is greater than or equal to certain number f assigned by the admiral, then “Victory” wins. Otherwise, “Glory” wins. The warship commanders are both mathematicians. After being assigned to such task, they see it is a Graph Theory problem. On the first simple directed non-cyclic connected graph, each node has a certain positive integer,it indicates the enemy firebases. The assignment is that two captains take turn to move forward along the directed edge until they are unable to do so. Then sum the total positive integers of the nodes on the routing path. Compare the number with the certain number f, and decides the final winning or losses. Therefore, when it is the time for their own navigation, they are supposed to choose the route to win the final success. Input There are several test cases, in each case there are three positive integers n, m and f in first line. n indicates there are n (1< n <10000 ) nodes in the graph. The node serial number is arranged from 1 to n. m indicates that there are m edges in the graph. The following line has n positive integers, which indicate in sequence the positive integers in the nodes. Finally, there are m lines, and each line has two positive integers a, b (1< = a, b< =n), indicating there is a directed edge from the a node to the b node. Input is terminated by the end of file. Output To each group of the test case, if “Victory” wins, then output “Victory”. Otherwise, output “Glory”. The output each case takes up one line. Sample Input 4 4 7 2 2 2 2 4 2 2 1 4 3 3 1 4 5 6 1 2 3 4 1 2 1 3 1 4 2 3 4 3 Sample Output Glory Victory
局部方法的形参定义为final,是否会提升程序的性能?
发现有个同事总喜欢将局部方法的参数全部定义为final的,如: [code="java"]public static void debug(final Logger logger, final boolean enableCheck, final Object message, final Throwable t){}[/code] 在方法体中也并没有用到内部类。 我想问的是这样的写法对程序的性能是有有影响?如果有,有什么影响,为什么? 我只知道final修饰基本类型,会在编译器优化掉。
Java中为什么匿名对象中方法,调用局部变量必须加final呢,求详解
Java中为什么匿名对象中方法,调用局部变量必须加final呢,求详解。在网上找了很久,基本没看到想要的答案,最好从Java虚拟机内存分配角度讲一讲,其他角度亦可。 老师只告诉这么用就好了,问了也说不知道,匿名对象在哪没研究过 求大神回复
No Left Turns 转弯的问题
Problem Description ALL HEADS: You're a Knight of the Round Table? ROBIN: I am. LEFT HEAD: In that case I shall have to kill you. MIDDLE HEAD: Shall I? RIGHT HEAD: Oh, I don't think so. MIDDLE HEAD: Well, what do I think? LEFT HEAD: I think kill him. RIGHT HEAD: Well let's be nice to him. MIDDLE HEAD: Oh shut up. As the story goes, the Knight scarpers off. Right Head has taken it upon himself to search the grounds for the knight so he, Left, and Middle can go extinguish him (and then have tea and biscuits.) Consider the following 8 by 12 maze, where shaded squares are walls that can’t be entered. The shortest path between the Right Head (denoted by the S, for start) and the knight (denoted by the F, for finish) is of length 3, as illustrated above. But! Right Head can’t turn left or make UTurns. He can only move forward and turn right. That means the shortest path that Right Head can find is significantly longer: at 29! Input The input file will consist of a single integer N (N > 0) specifying the number of mazes in the file. Following this, on a maze by maze basis will be the number of rows, r (3 < r <= 20), a space, then the number of columns, c (3 < c <= 20). After this will follow r lines of c characters, representing a map of the maze: XXXXXXXXXXXXXX X XXX X XFXXXXX X XXX XX XX X X S X XX XXXXXX X X X X X X X X X X X XXX XX X XXXXXXXXXXXXXX X’s mark those locations that are walls and can’t be occupied. S marks the start location, and F marks the Knight. Blanks are locations that can be freely traveled. Output The output is the length of the shortest path between the start and finish locations. Based on the above maze, your program would output the minimum no-left-turns path length of 29. Hint Additional Constraints/Information: Right Head is capable of moving from the start position in any of the four primary compass directions. After that, he’s constrained to either step forward or right. The start and end locations will never be the same. The maze is always surrounded by four walls. You can assume that a path between the start and final locations always exists. Sample Input 1 10 14 XXXXXXXXXXXXXX X XXX X XFXXXXX X XXX XX XX X X S X XX XXXXXX X X X X X X X X X X X XXX XX X XXXXXXXXXXXXXX Sample Output 29
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私有的数
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
此博客仅为我业余记录文章所用,发布到此,仅供网友阅读参考,如有侵权,请通知我,我会删掉。 补充 有不少读者留言说本文章没有用,因为天气预报直接打开手机就可以收到了,为何要多此一举发送到邮箱呢!!!那我在这里只能说:因为你没用,所以你没用!!! 这里主要介绍的是思路,不是天气预报!不是天气预报!!不是天气预报!!!天气预报只是用于举例。请各位不要再刚了!!! 下面是我会用到的两个场景: 每日下
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了无数
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外
大学四年自学走来,这些珍藏的「实用工具/学习网站」我全贡献出来了
知乎高赞:文中列举了互联网一线大厂程序员都在用的工具集合,涉及面非常广,小白和老手都可以进来看看,或许有新收获。
《阿里巴巴开发手册》读书笔记-编程规约
Java编程规约命名风格 命名风格 类名使用UpperCamelCase风格 方法名,参数名,成员变量,局部变量都统一使用lowerCamelcase风格 常量命名全部大写,单词间用下划线隔开, 力求语义表达完整清楚,不要嫌名字长 ...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前前言 为啥今天有个前前言呢? 因为你们的丙丙啊,昨天有牌面了哟,直接被微信官方推荐,知乎推荐,也就仅仅是还行吧(心里乐开花)
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca
Python爬虫精简步骤1 获取数据
爬虫的工作分为四步: 1.获取数据。爬虫程序会根据我们提供的网址,向服务器发起请求,然后返回数据。 2.解析数据。爬虫程序会把服务器返回的数据解析成我们能读懂的格式。 3.提取数据。爬虫程序再从中提取出我们需要的数据。 4.储存数据。爬虫程序把这些有用的数据保存起来,便于你日后的使用和分析。 这一篇的内容就是:获取数据。 首先,我们将会利用一个强大的库——requests来获取数据。 在电脑上安装
Python绘图,圣诞树,花,爱心 | Turtle篇
1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle() circle.shape('circle') circle.color('red') circle.speed('fastest') circle.up() square = turtle.Turtle()
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 更多有趣分析教程,扫描下方二维码关注vx公号「裸睡的猪」 即可查看! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ......
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
别低估自己的直觉,也别高估自己的智商
所有群全部吵翻天,朋友圈全部沦陷,公众号疯狂转发。这两周没怎么发原创,只发新闻,可能有人注意到了。我不是懒,是文章写了却没发,因为大家的关注力始终在这次的疫情上面,发了也没人看。当然,我...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。   再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。   下文是原回答,希望能对你能有所启发。   如果我说,这个世界上人真的分三六九等,
为什么听过很多道理,依然过不好这一生?
记录学习笔记是一个重要的习惯,不希望学习过的东西成为过眼云烟。做总结的同时也是一次复盘思考的过程。 本文是根据阅读得到 App上《万维钢·精英日课》部分文章后所做的一点笔记和思考。学习是一个系统的过程,思维模型的建立需要相对完整的学习和思考过程。以下观点是在碎片化阅读后总结的一点心得总结。
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合
如何优雅地打印一个Java对象?
你好呀,我是沉默王二,一个和黄家驹一样身高,和刘德华一样颜值的程序员。虽然已经写了十多年的 Java 代码,但仍然觉得自己是个菜鸟(请允许我惭愧一下)。 在一个月黑风高的夜晚,我思前想后,觉得再也不能这么蹉跎下去了。于是痛下决心,准备通过输出的方式倒逼输入,以此来修炼自己的内功,从而进阶成为一名真正意义上的大神。与此同时,希望这些文章能够帮助到更多的读者,让大家在学习的路上不再寂寞、空虚和冷。 ...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计
Linux 命令(122)—— watch 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] watch(1) manual
Linux 命令(121)—— cal 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] cal(1) manual
记jsp+servlet+jdbc实现的新闻管理系统
1.工具:eclipse+SQLyog 2.介绍:实现的内容就是显示新闻的基本信息,然后一个增删改查的操作。 3.数据库表设计 列名 中文名称 数据类型 长度 非空 newsId 文章ID int 11 √ newsTitle 文章标题 varchar 20 √ newsContent 文章内容 text newsStatus 是否审核 varchar 10 news...
Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕(三)发送篇
今天介绍的项目是使用 Itchat 发送统计报告 项目功能设计: 定时爬取疫情数据存入Mysql 进行数据分析制作疫情报告 使用itchat给亲人朋友发送分析报告(本文) 基于Django做数据屏幕 使用Tableau做数据分析 来看看最终效果 目前已经完成,预计2月12日前更新 使用 itchat 发送数据统计报告 itchat 是一个基于 web微信的一个框架,但微信官方并不允
相关热词 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数 c#日期精确到分钟 c#自定义异常必须继承 c#查表并返回值 c# 动态 表达式树 c# 监控方法耗时 c# listbox c#chart显示滚动条
立即提问