static

Java 方法

怎甘沉沦 提交于 2020-01-17 23:48:44
我们经常使用到 System.out.println() ,那么它是什么呢? print()就是一个方法。 System是系统类。 out是System类的一个对象,是一个标准输出对象。 这句代码的用法是调用系统类System中的输出对象out中的方法print(). 那么什么是方法呢? Java方法是语句的集合,它们在一起执行一个功能。 方法是解决一类问题的步骤的有序组合 方法包含于类或对象中 方法在程序中被创建,在其它地方被引用 方法的有点 使程序变得简洁清晰。 有利于程序维护。 可以提升程序开发的效率。 提高了代码的重用性。 方法的命名规则 方法名字第一个单词应以小写字母开头,后面的单词则以大写字母开头写,不用连接字符,遵循驼峰命名规则。例如: addPerson . 方法有两种 静态方法 , 用 static 修饰,与类一起加载。直接方法名就可以调用。 非静态方法,实例化(new)之后才存在.,必须用 new 关键词实例化才可以调用。 方法的定义 修饰符 返回值类型 方法名 (参数类型 参数名){ ... 方法体 ... return 返回值; } 修饰符: 修饰符,是可选的,告诉编译器如何调用该方法,定义了该方法的访问类型。 返回值类型: 方法可能会返回值。returnValueType是方法返回值的数据类型。有些方法执行的操作是没有返回值

GTK入门

早过忘川 提交于 2020-01-17 19:18:17
环境准备 官网 下载 GTK 源码包,因为本机 GLib 版本不够,下载一个非最新版的 GTK3.8.0 先学习用 直接阅读 "/gtk+-3.8.0/docs/reference/gtk/html/gtk-building.html" 进行操作 安装完毕, gtk3-demo 出来 gtk 的样例界面即安装搞定 实例学习 编译命令和编译脚本 编译参数包括 pkg-config --libs --cflags gtk+-3.0 为了方便,用脚本管理起来 build.sh #!/bin/bash if [ $# -lt 1 ]; then echo "usage: $0 [xxxx.c]" exit fi gcc -o $1_out $1 `pkg-config --libs --cflags gtk+-3.0` 一个简单的HelloWorld按钮 01_simple_button.c #include <gtk/gtk.h> // 回调函数1 void hello( GtkWidget *widget, GdkEvent *event, gpointer data ) { g_print("Hello World\n"); } // 回调函数2 void destroy( GtkWidget *widget, gpointer data ) { gtk_main_quit(); }

php中self static区别

我与影子孤独终老i 提交于 2020-01-17 10:20:03
准确说,后期静态绑定工作原理是存储了在上一个“非转发调用”(non-forwarding call)的类名。当进行静态方法调用时,该类名即为明确指定的那个(通常在 :: 运算符左侧部分);当进行非静态方法调用时,即为该对象所属的类。所谓的“转发调用”(forwarding call)指的是通过以下几种方式进行的静态调用:self::,parent::,static:: 以及 forward_static_call()。可用 get_called_class() 函数来得到被调用的方法所在的类名,static:: 则指出了其范围。 该功能从语言内部角度考虑被命名为“后期静态绑定”。“后期绑定”的意思是说,static:: 不再被解析为定义当前方法所在的类,而是在实际运行时计算的。也可以称之为“静态绑定”,因为它可以用于(但不限于)静态方法的调用。 self:: 的限制 使用 self:: 或者 __CLASS__ 对当前类的静态引用,取决于定义当前方法所在的类 来源: https://www.cnblogs.com/yisong-china/p/12204269.html

《Java技术》第二次作业--面向对象基础

梦想与她 提交于 2020-01-17 09:25:10
(一)学习总结 1.什么是构造方法?什么是构造方法的重载?下面的程序是否可以通过编译?为什么? public class Test { public static void main(String args[]) { Foo obj = new Foo(); } } class Foo{ int value; public Foo(int intValue){ value = intValue; } } 构造方法:没有返回值,名字与类名相同,当创建对象时会调用构造方法(如果没有写构造方法,那么编译器会自动添加无参构造方法); 构造方法的重载:当有多个构造方法时(无参,有参,以及参数不同的多种构造方法)会用到构造方法的重载; 该程序不能通过编译。因为定义了有参的构造方法,在编译时编译器不会再自动创建无参构造方法,而在调用构造方法时却又想调用无参构造方法; 解决办法:手动创建无参构造方法。 2.运行下列程序,结果是什么?分析原因,应如何修改。 public class Test { public static void main(String[] args) { MyClass[] arr=new MyClass[3]; arr[1].value=100; } } class MyClass{ public int value=1; } 结果:运行错误; 原因

Serve static content with Jersey 2.22.2

巧了我就是萌 提交于 2020-01-17 06:00:16
问题 I have a REST Api that I developed using Jersey, everything works fine when it comes to Json in / out. and that I'm consuming by Ajax. However, due to Cross-Domain limitations on the browsers, I'd like to package the static website (JS / Images / HTMLs / CSS) on my WAR This is how my web.xml looks like : <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml

Accessing static field from Class<A> variable

孤街醉人 提交于 2020-01-17 05:09:31
问题 I have the following situation (I know it doesn't sound real but I simplified it for better understanding): A class A , with a public static int f; declared Other classes B, C, D, ... that extend A A method foo (somewhere else, doesn't matter) with the following signature: int foo(Class< A> classz); Now I want this method implementation to return the value if the static field f , from the class represented by classz ; subclasses of A may have different values. I don't want to use reflection

How do you handle shared members when dealing with interfaces?

不问归期 提交于 2020-01-17 05:03:49
问题 So I did tons and tons of work trying to make an interface for a common set of classes. The idea was to make an interface that each class could use within the set, but ultimately each class is different. Turns out interfaces do not like shared members. What I tried: Public Interface ISomeInterface Shared Property Meta() as Object End Interface Public Class A Implements ISomeInterface Shared Public Property Meta() as Object Implements ISomeInterFace.Meta 'Set/get methods End Propery Public

Django入门教程(八):文件上传和下载

故事扮演 提交于 2020-01-17 04:01:28
大家好,我是连人。本期我们继续分享文件的上传和下载。 首先,在static中下创建一个新的文件夹file。 当然你也可以在与static和templates的同级下新建一个文件夹,但此时需要通过settings.py将这个文件夹注册成静态文件夹,方法和设置static一样。 接下来看 views.py : import os from django . http import StreamingHttpResponse , Http404 from django . shortcuts import render , redirect def upload ( request ) : if request . method == 'POST' : file = request . FILES . get ( "file" , None ) if not file : message = "no files for upload!" return render ( request , 'file.html' , locals ( ) ) if not file . name . endswith ( ".jpg" ) : # 检测是否为jpg,防止文件上传攻击 message = "only JPG is accepted!" return render ( request ,

Help Deadlock analysis

╄→尐↘猪︶ㄣ 提交于 2020-01-17 03:22:26
问题 The Deadlock occurs in my application when initialization of local static variable happens in the function called from DLLMain Entry point with param DLL_THREAD_DETACH. Below is Windbg analysis This is usually caused by another thread holding the loader lock. Following are the Locks Held. CritSec ntdll!LdrpLoaderLock+0 at 7c97e178 LockCount 3 RecursionCount 1 OwningThread 17e8 EntryCount d ContentionCount d *** Locked CritSec MSVCR80!__app_type+94 at 781c3bc8 LockCount 1 RecursionCount 1

C#学习之修饰符

霸气de小男生 提交于 2020-01-17 01:04:45
修饰符作用: 修饰符用于限定类型以及类型成员的申明。 C#中修饰符种类: C#中有 13种修饰符 ,按功能可分为三部分: 存取修饰符,类修饰符和成员修饰符 . 存取修饰符: public:存取 访问不受限制 . private:只有包含该成员的类可以存取 .当前类才能访问 internal:只有当前工程可以存取. 只限于类所在的命名空间 (不包括子类) protected: 只有包含该成员的类以及继承的类可以存取 . 类修饰符: abstract:抽象类, 可以被指示一个类只能作为其它类的基类.必须被继承和重写的 sealed: 密封类,指示一个类不能被继承 .防止该类被其它类继承 partial: 部分类,可以将一个 类、结构或接口的定义拆分到两个或多个源文件中,最终编译时将合并成一个文件 ,且各个部分 不能分散在不同程序集中。 成员修饰符: abstract:指示该方法或属性没有实现.只能在抽象类中声明 const:指定域或局部变量的值 不能被改动 . event:声明一个事件. extern: 指示方法在外部实现 . override:对由基类继承成员的新实现. readonly:指示一个域只能在声明时以及相同类的内部被赋值. static: 指示一个成员属于类型本身 ,而不是属于特定的对象. virtual: 指示一个方法或存取器的实现可以在继承类中被覆盖 .