当前位置: 首页 > 编程日记 > 正文

《Java 8 实战》(二)—— Lambda

Lambda表达式可以理解为简洁地表示可传递的匿名函数的一种方式:它没有名称,但它有参数列表/函数主体/返回类型,可能还有一个可以抛出的异常列表。

Lambda表达式由参数/箭头和主体组成:

(Apple a1, Apple a2)  -> a1.getWeight().compareTo(a2.getWeight());

之前的代码形式:

Comparator<Apple> byWeight = new Comparator<Apple>() {
  public int compare(Apple a1, Apple a2) {

return a1.getWeight().compareTo(a2.getWeight());

}

}

Java 8 中有效的Lambda表达式:

1,  (String s) -> s.length()

具有一个String类型的参数,并返回一个int。Lambda表达式没有return语句,因为已经隐含了return。

2,  (Apple a) -> a.getWeight() > 150

参数为Apple类型,返回一个boolean类型。

3,  (int x, int y) -> {

System.out.println("Result");

System.out.println(x+y);

}

该Lambda表达式具有两个int类型的参数而没有返回值。Lambda表达式可以包含多行语句。

() -> {return "Mario";}

该Lambda表达式也是有效的。

4, () - > 42

该Lambda表达式没有参数,返回一个int

5, (Apple a1, Apple a2) -> a1.getWeight().compareTo(a2.getWeight())

该表达式具有两个Apple类型的参数,返回一个int

无效Lambda表达式:

(Integer i) -> return "Alan" + i;

(String s) -> {"IronMan";}

第一个表达式中,return是一个控制流语句。要使得这个语句有效,需要加上花括号。

第二个表达式中,"IronMan" 是一个表达式,不是语句。要使得此Lambda有效,可以去除花括号和分号。

Lambda基本语法:

(parameters) -> expression

or

(parameters) -> { statements;}

可以使用Lambda表达式的地方 —— 函数式接口

只有在接受函数式接口的地方才可以使用Lambda表达式。

函数式接口就是只定义一个抽象方法的接口。如Comparator和Runnable接口。

Lambda表达式可以直接以内联的形式为函数式接口的抽象方法提供实现,并把整个表达式作为函数式接口的实例。

函数式接口的抽象方法的签名就是Lambda表达式的签名。这种抽象方法叫做函数描述符。

新的Java API中,函数式接口带有@FunctionalInterface的标注。如果用@FunctionalInterface定义了一个接口,但它却不是函数式接口的话,便一起将返回一个提示原因的错误,例如“Multiple non-overriding abstract methods found in interface Foo”,表明存在多个抽象方法。

使用Lambda表达式的步骤:

1,行为参数化:

提取Lambda表达式,设计好参数,函数主体和返回值。

2,使用函数式接口来传递行为:

创建一个能匹配Lambda表达式的函数式接口I,并把这个接口作为参数传递给需要使用Lambda表达式的函数M。

3,执行函数式接口中的行为

在函数M中调用接口I中的抽象函数

4,传递Lambda表达式

常用函数式接口:

Java 8 以前已有的函数式接口:

Comparable

Runnable

Callable

Java 8 在java.util.function包中引入的新的函数式接口:

Predicate

@FunctionalInterface
public interface Predicate<T>{boolean test(T t);
}
public static <T> List<T> filter(List<T> list, Predicate<T> p) {List<T> results = new ArrayList<>();for(T s: list){if(p.test(s)){results.add(s);}}return results;
}
Predicate<String> nonEmptyStringPredicate = (String s) -> !s.isEmpty();
List<String> nonEmpty = filter(listOfStrings, nonEmptyStringPredicate);

Consumer

@FunctionalInterface
public interface Consumer<T>{void accept(T t);
}
public static <T> void forEach(List<T> list, Consumer<T> c){    for(T i: list){c.accept(i);}
}
forEach(Arrays.asList(1,2,3,4,5),(Integer i) -> System.out.println(i));

Function

@FunctionalInterface
public interface Function<T, R>{R apply(T t);
}
public static <T, R> List<R> map(List<T> list,Function<T, R> f) {List<R> result = new ArrayList<>();for(T s: list){result.add(f.apply(s));}return result;
}List<Integer> l = map(Arrays.asList("lambdas","in","action"),(String s) -> s.length());

Lambda及函数式接口例子

使用案例 Lambda的例子 对应的函数式接口
布尔表达式 (List<String> list) -> list.isEmpty()  Predicate<List<String>>
创建对象 () -> new Apple(10)Supplier<Apple>
消费一个对象(Apple a) -> System.out.println(a.getWeight())

 

Consumer<Apple>

 从一个对象中选择/提取 (String s) -> s.length() 

Function<String, Integer>或
ToIntFunction<String>

 合并两个值 (int a, int b) -> a * b IntBinaryOperator
比较两个对象  

(Apple a1, Apple a2) ->
a1.getWeight().compareTo(a2.getWeight())

 

Comparator<Apple>或
BiFunction<Apple, Apple, Integer>
或ToIntBiFunction<Apple, Apple>

函数式接口异常:

任何函数式接口都不允许抛出受检异常(checked Exception。 如果需要Lambda表达式抛出异常,有两种方式:

1,定义一个自己的函数式接口,并声明受检异常:

@FunctionalInterface
public interface BufferedReaderProcessor {String process(BufferedReader b) throws IOException;
}
BufferedReaderProcessor p = (BufferedReader br) -> br.readLine();

2,把Lambda包在一个try/cache块中。

Function<BufferedReader, String> f = (BufferedReader b) -> {try {return b.readLine();}catch(IOException e) {throw new RuntimeException(e);}
};

Lambda表达式类型检查:

Lambda的类型是从使用Lambda的上下文推断出来的。上下文中Lambda表达式需要的类型成为目标类型。例如:

List<Apple> heavierThan150g = filter(inventory, (Apple a) -> a.getWeight() > 150);

类型检查过程:

1,找出filter方法的声明

2,要求它是predicate<Apple>对象的第二个正式参数。

3,Predicate<Apple>是一个函数式接口,定义了一个叫做test的抽象方法。

4,test方法描述了一个函数描述符,它可以接受一个Apple,并返回一个boolean.

5, filter的任何实际参数都匹配这个要求。

Lambda表达式类型推断:

编译器可以了解Lambda表达式的参数类型,这样可以在Lambda语法中省去标注参数类型,即:

List<Apple> greenApples = filter(inventory, a -> "green".equals(a.getColor()));

但有时显式写出类型更易读,有时候去掉更易读,需要自己权衡。

当Lambda仅有一个类型需要推断的参数时,参数名称两边的括号也可以省略。

方法引用:

参考:http://www.cnblogs.com/chenpi/p/5885706.html

什么是方法引用

简单地说,就是一个Lambda表达式。在Java 8中,我们会使用Lambda表达式创建匿名方法,但是有时候,我们的Lambda表达式可能仅仅调用一个已存在的方法,而不做任何其它事,对于这种情况,通过一个方法名字来引用这个已存在的方法会更加清晰,Java 8的方法引用允许我们这样做。方法引用是一个更加紧凑,易读的Lambda表达式,注意方法引用是一个Lambda表达式,其中方法引用的操作符是双冒号"::"。

方法引用例子

先看一个例子

首先定义一个Person类,如下:

复制代码
package methodreferences;import java.time.LocalDate;public class Person
{public Person(String name, LocalDate birthday){this.name = name;this.birthday = birthday;}String name;LocalDate birthday;public LocalDate getBirthday(){return birthday;}public static int compareByAge(Person a, Person b){return a.birthday.compareTo(b.birthday);}@Overridepublic String toString(){return this.name;}
}
复制代码

假设我们有一个Person数组,并且想对它进行排序,这时候,我们可能会这样写:

原始写法

复制代码
package methodreferences;import java.time.LocalDate;
import java.util.Arrays;
import java.util.Comparator;public class Main
{static class PersonAgeComparator implements Comparator<Person> {public int compare(Person a, Person b) {return a.getBirthday().compareTo(b.getBirthday());}}public static void main(String[] args){Person[] pArr = new Person[]{new Person("003", LocalDate.of(2016,9,1)),new Person("001", LocalDate.of(2016,2,1)),new Person("002", LocalDate.of(2016,3,1)),new Person("004", LocalDate.of(2016,12,1))};Arrays.sort(pArr, new PersonAgeComparator());System.out.println(Arrays.asList(pArr));}
}
复制代码

其中,Arrays类的sort方法定义如下:

public static <T> void sort(T[] a, Comparator<? super T> c)

这里,我们首先要注意Comparator接口是一个函数式接口,因此我们可以使用Lambda表达式,而不需要定义一个实现Comparator接口的类,并创建它的实例对象,传给sort方法。

使用Lambda表达式,我们可以这样写:

改进一,使用Lambda表达式,未调用已存在的方法

复制代码
package methodreferences;import java.time.LocalDate;
import java.util.Arrays;public class Main
{public static void main(String[] args){Person[] pArr = new Person[]{new Person("003", LocalDate.of(2016,9,1)),new Person("001", LocalDate.of(2016,2,1)),new Person("002", LocalDate.of(2016,3,1)),new Person("004", LocalDate.of(2016,12,1))};Arrays.sort(pArr, (Person a, Person b) -> {return a.getBirthday().compareTo(b.getBirthday());});System.out.println(Arrays.asList(pArr));}
}
复制代码

然而,在以上代码中,关于两个人生日的比较方法在Person类中已经定义了,因此,我们可以直接使用已存在的Person.compareByAge方法。

改进二,使用Lambda表达式,调用已存在的方法

复制代码
package methodreferences;import java.time.LocalDate;
import java.util.Arrays;public class Main
{public static void main(String[] args){Person[] pArr = new Person[]{new Person("003", LocalDate.of(2016,9,1)),new Person("001", LocalDate.of(2016,2,1)),new Person("002", LocalDate.of(2016,3,1)),new Person("004", LocalDate.of(2016,12,1))};Arrays.sort(pArr, (a, b) -> Person.compareByAge(a, b));System.out.println(Arrays.asList(pArr));}
}
复制代码

因为这个Lambda表达式调用了一个已存在的方法,因此,我们可以直接使用方法引用来替代这个Lambda表达式,

改进三,使用方法引用

复制代码
package methodreferences;import java.time.LocalDate;
import java.util.Arrays;public class Main
{public static void main(String[] args){Person[] pArr = new Person[]{new Person("003", LocalDate.of(2016,9,1)),new Person("001", LocalDate.of(2016,2,1)),new Person("002", LocalDate.of(2016,3,1)),new Person("004", LocalDate.of(2016,12,1))};Arrays.sort(pArr, Person::compareByAge);System.out.println(Arrays.asList(pArr));}
}
复制代码

在以上代码中,方法引用Person::compareByAge在语义上与Lambda表达式 (a, b) -> Person.compareByAge(a, b) 是等同的,都有如下特性:

  • 真实的参数是拷贝自Comparator<Person>.compare方法,即(Person, Person);
  • 表达式体调用Person.compareByAge方法;

四种方法引用类型

静态方法引用

我们前面举的例子Person::compareByAge就是一个静态方法引用。

特定实例对象的方法引用

如下示例,引用的方法是myComparisonProvider 对象的compareByName方法;

复制代码
        class ComparisonProvider{public int compareByName(Person a, Person b){return a.getName().compareTo(b.getName());}public int compareByAge(Person a, Person b){return a.getBirthday().compareTo(b.getBirthday());}}ComparisonProvider myComparisonProvider = new ComparisonProvider();Arrays.sort(rosterAsArray, myComparisonProvider::compareByName);
复制代码

任意对象(属于同一个类)的实例方法引用

如下示例,这里引用的是字符串数组中任意一个对象的compareToIgnoreCase方法。

        String[] stringArray = { "Barbara", "James", "Mary", "John", "Patricia", "Robert", "Michael", "Linda" };Arrays.sort(stringArray, String::compareToIgnoreCase);

构造方法引用

如下示例,这里使用了关键字new,创建了一个包含Person元素的集合。

Set<Person> rosterSet = transferElements(roster, HashSet<Person>::new);
transferElements方法的定义如下,功能为集合拷贝,
复制代码
public static <T, SOURCE extends Collection<T>, DEST extends Collection<T>>DEST transferElements(SOURCE sourceCollection,Supplier<DEST> collectionFactory) {DEST result = collectionFactory.get();for (T t : sourceCollection) {result.add(t);}return result;
}
复制代码

什么场景适合使用方法引用

当一个Lambda表达式调用了一个已存在的方法

什么场景不适合使用方法引用

当我们需要往引用的方法传其它参数的时候,不适合,如下示例:

IsReferable demo = () -> ReferenceDemo.commonMethod("Argument in method.");

Lambda 和 方法引用实战

第一步,传递代码

public class AppleComparator implements Comparator<Apple> {public int compare(Apple a1, Apple a2) {return a1.getWeight().compareTo(a2.getWeight());}
}inventory.sort(new AppleComparator());

第二步,使用匿名类

inventory.sort(new Comparator<Apple>() {public int compare(Apple a1, Apple a2) {return a1.getWeight().compareTo(a2.getWeight());}
})

第三步,使用Lambda表达式

inventory.sort((Apple a1, Apple a2) -> a1.getWeight().compareTo(a2.getWeight()));

Java编译器可以根据Lambda出现的上下文来推断Lambda表达式参数的类型,所以可以改写为:

inventory.sort((a1, a2) -> a1.getWeight().compareTo(a2.getWeight()));

Comparator具有一个叫做comparing的静态方法,可以接受一个Function来提取Comparable键值,并生成一个Comparator对象,如下:

Comparator<Apple> c = Comparator.comparing((Apple a) -> a.getWeight());

所以再次改写:

inventory.sort(comparing((a) -> a.getWeight()));

第四步,使用方法引用

inventory.sort(comparing(Apple::getWeight));

复合Lambda表达式

1,比较器复合

a,逆序

inventory.sort(comparing(Apple::getWeight).reversed())

b, 比较器链

inventory.sort(comparing(Apple::getWeight).reversed().thenComparing(Apple::getCountry));

2, 谓词复合

a,negate

Predicate<Apple> notRedApple = redApple.negate();

b, and

Predicate<Apple> redAndHeavyApple = redApple.and(a -> a.getWeight() > 150);

c, or

Predicate<Apple> redAAndHeavyAppleOrGreen = redApple.and(a -> a.getWeight() > 150).or(a -> "green".equals(a.getColor()));

3, 函数复合

a,andThen 相当于g(f(x))

Function<Integer, Integer> f = x -> x + 1;
Function<Integer, Integer> g = x -> x * 2;
Function<Integer, Integer> h = f.andThen(g);
int result = h.apply(1); // result = 4

b, compose 相当于f(g(x))

Function<Integer, Integer> f = x -> x + 1;
Function<Integer, Integer> g = x -> x * 2;
Function<Integer, Integer> h = f.compose(g);
int result = h.apply(1); // result = 3

转载于:https://www.cnblogs.com/IvySue/p/6737133.html

相关文章:

c++回调函数 callback

&#xff08;1&#xff09;Callback方式Callback的本质是设置一个函数指针进去&#xff0c;然后在需要需要触发某个事件时调用该方法, 比如Windows的窗口消息处理函数就是这种类型。比如下面的示例代码&#xff0c;我们在Download完成时需要触发一个通知外面的事件&#xff1a;…

【微信小程序之画布】终:手指触摸画板实现

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 先看效果图&#xff1a; wxml <!--pages/shouxieban/shouxieban.wxml--> <view class"container"><view>手写板&#xff08;请在下方区域手写内容&…

Android开发中应避免的重大错误

by Varun Barad由Varun Barad Android开发中应避免的重大错误 (Critical mistakes to avoid in Android development) As many pioneers and leaders in different fields have paraphrased:正如许多不同领域的开拓者和领导人所说&#xff1a; In any endeavor, it is import…

机房收费系统(VB.NET)——超具体的报表制作过程

之前做机房收费系统用的报表是GridReport&#xff0c;这次VB.NET重构中用到了VisualStudio自带的报表控件。刚開始当然对这块功能非常不熟悉&#xff0c;只是探究了一段时间后还是把它做出来了。 以下把在VisualStudio&#xff08;我用的是VisualStudio2013&#xff0c;假设与您…

微信小程序实现画布自适应各种手机尺寸

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 解决的问题&#xff1a; 画布&#xff0c;动画等js里面的操作&#xff0c;默认是px而不是rpx, 无法根据手机屏幕自适应 达到的效果&#xff1a; 让画布&#xff0c;动画在不同分辨…

网易新闻首页实现

http://www.2cto.com/kf/201409/330299.html IOS后台运行机制详解&#xff08;二&#xff09; http://blog.csdn.net/enuola/article/details/9148691转载于:https://www.cnblogs.com/itlover2013/p/4403061.html

阿联酋gitex_航空公司网站不在乎您的隐私后续行动:阿联酋航空以以下方式回应我的文章:...

阿联酋gitexby Konark Modi通过Konark Modi 航空公司网站不在乎您的隐私后续行动&#xff1a;阿联酋航空对我的文章进行了全面否认 (Airline websites don’t care about your privacy follow-up: Emirates responds to my article with full-on denial) Yesterday, The Regis…

微信小程序把缓存的数组动态渲染到页面

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 代码实现的目的&#xff1a;当页面销毁的时候&#xff0c;页面的参数状态还是能够保存。 show_img函数实现&#xff1a; 创建一个数组保存到缓存&#xff0c;遍历缓存的list_stutas对…

Find Minimumd in Rotated Sorted Array

二分搜索查最小数&#xff0c;from mid to分别为区间的第一个&#xff0c;中位数&#xff0c;和最后一个数 if(from<mid&&mid<to)//顺序&#xff0c;第一个即为最小值 return from; if(from>mid)//发现逆序&#xff0c;则最小值在这个区间&#xff0c;2分搜索…

在DataTable中更新、删除数据

在DataTable中选择记录 /*在DataTable中选择记录*//* 向DataTable中插入记录如上&#xff0c;更新和删除如下:* ----但是在更新和删除前&#xff0c;首先要找出要更新和删除的记录。* 一种方法是遍历DataRow&#xff0c;搜索想要的记录&#xff0c;* --〉然而更聪明的办法是使用…

使用TensorFlow进行机器学习即服务

by Kirill Dubovikov通过基里尔杜博维科夫(Kirill Dubovikov) 使用TensorFlow进行机器学习即服务 (Machine Learning as a Service with TensorFlow) Imagine this: you’ve gotten aboard the AI Hype Train and decided to develop an app which will analyze the effective…

浏览器加载、解析、渲染的过程

最近在学习性能优化&#xff0c;学习了雅虎军规 &#xff0c;可是觉着有点云里雾里的&#xff0c;因为里面有些东西虽然自己也一直在使用&#xff0c;但是感觉不太明白所以然&#xff0c;比如减少DNS查询&#xff0c;css和js文件的顺序。所以就花了时间去了解浏览器的工作&…

《转》java设计模式--工厂方法模式(Factory Method)

本文转自&#xff1a;http://www.cnblogs.com/archimedes/p/java-factory-method-pattern.html 工厂方法模式&#xff08;别名&#xff1a;虚拟构造&#xff09; 定义一个用于创建对象的接口&#xff0c;让子类决定实例化哪一个类。Factory Method使一个类的实例化延迟到其子类…

微信小程序去除左上角返回的按钮

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 解决方法有两种&#xff1b; 1.把该页面设置为tab页面或者主页 ; 2.进入该页面使用 wx.reLaunch(); 示例 wx.reLaunch({url: ../detail/detail,}) 这样有一个弊端&#xff0c;就是…

我的第一个web_登陆我的第一个全栈Web开发人员职位

我的第一个webby Robert Cooper罗伯特库珀(Robert Cooper) 登陆我的第一个全栈Web开发人员职位 (Landing My First Full Stack Web Developer Job) This is the story of the steps I took to get my first job as a full stack web developer. I think it’s valuable to sha…

HTTP请求报文和HTTP响应报文(转)

原文地址&#xff1a;http://blog.csdn.net/zhangliang_571/article/details/23508953 HTTP报文是面向文本的&#xff0c;报文中的每一个字段都是一些ASCII码串&#xff0c;各个字段的长度是不确定的。HTTP有两类报文&#xff1a;请求报文和响应报文。 HTTP请求报文 一个HTTP请…

微信小程序用户未授权bug解决方法,微信小程序获取用户信息失败解决方法

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; bug示例图&#xff1a; 导致这个bug的原因是 wx.getUserInfo(OBJECT) 接口做了调整&#xff1b; 请看官方文档的描述&#xff1a; wx.getUserInfo(OBJECT) 注意&#xff1a;此接口有…

格式化json日期'/Date(-62135596800000)/'

日期经过json序列化之后&#xff0c;变成了/Date(-62135596800000)/字符串&#xff0c;在显示数据时&#xff0c;我们需要解释成正常的日期。 Insus.NET和js库中&#xff0c;写了一个jQuery扩展方法&#xff1a; $.extend({JsonDateParse: function (value) {if (value /Date(…

aws lambda使用_使用AWS Lambda安排Slack消息

aws lambda使用Migrating to serverless brings a lot of questions. How do you do some of the non-serverless tasks, such as a cronjob in a serverless application?迁移到无服务器带来了很多问题。 您如何执行一些非无服务器的任务&#xff0c;例如无服务器应用程序中的…

微信小程序模块化开发 include与模板开发 template

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 1. include 是引用整个wxml文件&#xff0c;我通常会配合js&#xff0c;css一起使用&#xff1b; 使用场景&#xff0c;需要封装事件和微信 api 的公共模块。 2.template &#xff…

winform解析json

在使用C#开发爬虫程序时&#xff0c;会遇到需要解析json字符串的情况。对于json字符串可以使用正则表达式的形式进行解析&#xff0c;更为方便的方法是使用Newtonsoft.Json来实现。 Nuget添加应用包 在工程上右键——【管理Nuget程序包】浏览找到要安装的程序包Newtonsoft.Jso…

Oracle11g密码忘记处理方法

c:\>sqlplus /nolog sql>connect / as sysdba sql>alter user 用户名 identified by 密码;&#xff08;注意在这里输入的密码是区分大小写的&#xff09; 改完之后你可以输入 sql>connect 用户名/密码 as sysdba进行验证 转载于:https://www.cnblogs.com/imhuanxi…

hic染色体构想_了解微服务:从构想到起点

hic染色体构想by Michael Douglass迈克尔道格拉斯(Michael Douglass) 了解微服务&#xff1a;从构想到起点 (Understanding Microservices: From Idea To Starting Line) Over the last two months, I have invested most of my free time learning the complete ins-and-outs…

[python]关于字符串查找和re正则表达式的效率对比

最近需要在python中做大日志文件中做正则匹配 开始直接在for in 中每行做re.findall&#xff0c;后来发现&#xff0c;性能不行&#xff0c;就在re前面做一个基本的字符串包含判断 (str in str)&#xff0c;如果不包含直接continue 效率对比&#xff1a; 1、只做一次包含判断&a…

微信小程序客服功能 把当前页面的信息卡片发送给客服

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 需求&#xff1a;微信小程序客服带详情页 &#xff0c; 场景&#xff1a;一个人通过微信小程序接入微信客服&#xff0c;聊天后带上入口链接 效果图&#xff1a; 写法&#xff1a; …

phpcms标签大全V9

转自&#xff1a;http://blog.csdn.net/cloudday/article/details/7343448调用头部 尾部{template "content","header"} 、 {template "content","footer"}{siteurl($siteid)} 首页链接地址 <a href"{siteurl($siteid)}/&q…

多伦多到温莎_我想要freeCodeCamp Toronto的Twitter来发布报价,所以我做了一个免费的bot来做到这一点。...

多伦多到温莎If you read About time, you’ll know that I’m a big believer in spending time now on building things that save time in the future. To this end, I built a simple Twitter bot in Go that would occasionally post links to my articles and keep my ac…

Linux常用命令汇总(持续更新中)

命令说明注意点cat access.log | wc -l统计行数awk命令可以做到同样的想过&#xff1a;cat access.log | awk END {print NR}grep vnc /var/log/messages查看系统报错日志等同于&#xff1a;sudo dmesg -T | grep "(java)"netstat -lnt | grep 590*查看端口状态 nets…

IOS问题汇总:2012-12-18 UIAlertView+UIActionSheet

UIAlertView/UIActionSheet UIAlertView * alertView [[UIAlertView alloc] initWithTitle:“添加场景模式” message:“请输入场景名称” delegate:self cancelButtonTitle:“取消” otherButtonTitles:“确定”, nil];alertView.alertViewStyle UIAlertViewStylePlainTextI…

PHP入门 1 phpstudy安装与配置站点

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1&#xff0c; 一键安装 phpstudy &#xff1b; 点击跳转下载&#xff1b; 2.配置站点&#xff0c;点击MySQL 其它选项菜单的站点域名管理&#xff1b;再点击新增 2&#xff0c;点击其他选项菜单点击打开…