As a result of the recent online search for a lot of Android connection to the HTTP method, but 2013 years ago, the method can not be used now, or error, or abandoned, the years left behind the things can only be sorted by themselves.It's really simple, just a httputil generic class. Can implement get and post method, other things, inside can be arbitrarily changed, basically so.parameter, I used a strurlpath URL, params key-value pair, encode code (such as Utf-8). Package Utilimport Android.o
There's something new in the enumeration class in Kotlin: The constant of an enumeration class can be seen as an anonymous class with the same name.Since it is a class, it can be associated with a methodCheck the code of the official websiteIf you have experienced the use of enumerations in other languages, you may be confused by this definition and explanation.I'll give you an example and a result, and you'll be much clearer.Enum class Protocolstate
According to the current development model and some information on the internet, Springboot needs to be layered into business and operations, usually divided into controllers, entity, service, respository and other structures. Below is the Kotlin official website example, explains in the stratification time, needs to do what configuration.1, in the package com. Springbootusekotlin New Package entity, add a new class, named People Packagecom.kotlinSpri
Read a piece of code first
private var Cloth_rv:recyclerview = null
cloth_rv!!. Sethasfixedsize (True)
。 : Indicates whether the current object can be empty
。。 : Indicates that the current object is not empty for execution
It's all kotlin for us. Methods for examining null pointers
"Kotlin Grammar Foundation to actual combat development" series course video
Http://edu.csdn.net/course/detail/6409?
Returns and Jumps
Like Java, there are 3 jump statements in Kotlin return break continue break and Continue tags
We can give an alias to any expression, Kotlin call this a label.
Take an example of the previous for Loop statement
Doctorq@for (index in array.indices) {
println (index)
}
I've added a label to this for loop, with a suffix of @
doctorq@ for (i-1..100) {
doctorq2@ for (J-in
The error is as follows:Exception encountered during context initialization-cancelling refresh attempt: Org.springframework.beans.factory.parsing.BeanDefinitionParsingException:Configuration problem: @Configuration Class ' Bugsnagclient ' May is not final. Remove The final modifier to continue. Offending Resource:class path resource [Com/rollong/chinatower/server/exception/bugsnag/bugsnagclient.class]The code should:Please add open before the funThe "Kotlin
a folder in which the war package will contain all dependent libraries (Java project depends on the most of the library is a jar package)In addition, I added the following in my gradle configuration file:apply plugin: "war"apply plugin: ‘application‘mainClassName = ‘com.ysl.jna.JnaApplicationKt‘(At the moment I don't know if it really works)The packaged operation is done here after you can choose the form you want to pack (or both forms of the package) after the package is finished, you will fi
until the completion of the process, corresponding to a stack frame in the virtual machine stack from the stack to the process.The Java Virtual machine stack holds local variable tables, such as the various basic data types known at compile time (Boolean, Byte, char, short, int, float, long, double), object reference (reference type, which is not equivalent to the object itself). Depending on the virtual machine implementation, it may be a reference pointer to the starting address of the object
Introduction to common operators and usages appearing in Kotlin
. Operator
Indicates that this object may be empty
Add a question mark after the variable type, representing the variable as a nullable variable
var name:string? = "Zhangsan"
/**
* If Str cannot be converted to INT type, then return null
/Fun parseint (str:string): Int? {
//(code slightly)
}
B?. Length//If B is non-null, return b.length, otherwise null, the type of the express
Kotlin commonly used operator 1, Elvis operator?:
If the left expression is not empty, the Elvis operator returns the result on the left, otherwise it returns the result on the right.Note that the expression on the right only evaluates when the left side is empty
Val a = b?. Length?:-1
//equivalent to:
val a:int = if (b!= null) B.length else-12, safe conversion as?
When using as transformation, classcastexception may often appear. So, now you can ma
Reference
Official website class
Defines a class by using the Class keyword.
All classes in Kotlin inherit from any class, and the any class has only hashcode,tostring and equals three methods.
A class is composed of the class name, the class header, and the body of the class-the main body of the class, which is wrapped up in braces-three parts. Where class headers, class bodies are optional. If there is no class body, the curly braces can be omitted.
Java. var and Val all member variables (including defined in the class and directly defined in the KT file) must be initialized when defined, and local variables (defined within the method) can be uninitialized. Such as:
var s:string? = null
var s2:string = ""
Fun Main (args:arrayS,s2,test three variables in the above code must be initialized, but not m is not required.
var: defines a variable variable.
Val: Defining constants, the defined variables are final types. such as
Control Flow If expression
In Kotlin, if is an expression that has a return value. But does not support three mesh operations
Val A = 1
val b = 2
var max = a
if (a
If the if branch is a block of code, the last expression of the code block defaults to the return value
Val max4 = if (a > B) {
print ("Choose a")
a
} else {
print ("Choose B")
b
}
If an if expression returns a result or if an if expres
Arrays are represented by arrayThere are three ways to initialize a number group:var = arrayof (array1:arrayvar array2:arrayvar array3:arrayKotlin also has a specialized class with no boxing overhead to represent arrays of native types: ByteArray, Shortarray, Intarray, and so on. These classes and arrays have no inheritance relationships, but they have the same set of method properties.The array type of the basic type of Kotlin (number, character, Boo
parameter, but it is not the first parameter.
When called, the parameter B is assigned by means of the parameter name = value, otherwise the assigned value is passed to the variable parameter a.
To turn on the class of the KT file above, you can find that the corresponding Java code for this function is as follows:
As you can see, variable parameter A has become a string array. Generic type
Specify the generic type by
Fun Main (args:arrayThis functionality is equivalent to extending the funct
When testing the Kotlin, we need a main function entry that is the same as the Java language, so be careful how you create it.
Right-click
Select the File type when you create a new item here.When you click OK, you create a. kt file that basically has nothing but a package xx.Then enter main return, the final generated main function:
Fun Main (args:array
After generating the main function, we can create the class directly in the current. kt file
Article Description: to the open beta-bean in the Product Shopping guide page after testing some feelings. From the results of the overall test, although the prototype of the commodity Shopping guide has been formed, but watercress to be in the field of electrical business, the road ahead to go a long way. After all, this is only watercress use of commodity shopping gui
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.