在css下面设置两个div的单独背景; 如果图像不符合div大小,则图像会重复出现.
如何使用css拉伸图像以适应div所需的空间?
<style type="text/css">
#contentMain {
margin-bottom: 5%;
margin-top: 10%;
margin-left: 10%;
margin-right: 10%;
background: url( /jQuery/mypage/img/background1.png )
}
#page1 {
background: url( /jQuery/mypage/img/background2.png )
}
</style>
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个scala函数,它将递归地对列表中的值求和.这是我到目前为止:
def sum(xs: List[Int]): Int = {
val num = List(xs.head)
if(!xs.isEmpty) {
sum(xs.tail)
}
0
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何将各个Int值相加作为函数的一部分.我正在考虑在函数sum中定义一个新函数,并使用一个局部变量,该函数在List迭代时对值进行求和.但这似乎是一种必要的方法.有替代方法吗?
我只是想了解下面的代码:
这里声明了一个新类型别名Set,它是一个接受Int参数并返回布尔值的函数
type Set = Int => Boolean
Run Code Online (Sandbox Code Playgroud)
这里声明了一个新方法'contains',它接受一个类型为Set和Int的参数,它返回一个布尔值.boolean设置为前面声明的函数('type Set = Int => Boolean')但是执行了什么逻辑来确定Int'elem'是否是Set's'的成员
def contains(set: Set, elem: Int): Boolean = set(elem)
Run Code Online (Sandbox Code Playgroud)
这里定义了一个方法,它返回一个返回函数的集合?
def singletonSet(elem: Int): Set = set => set == elem
Run Code Online (Sandbox Code Playgroud)
带注释的完整代码:
/**
* We represent a set by its characteristic function, i.e.
* its `contains` predicate.
*/
type Set = Int => Boolean
/**
* Indicates whether a set contains a given element.
*/
def contains(set: Set, elem: Int): Boolean = set(elem)
/**
* Returns the set …Run Code Online (Sandbox Code Playgroud) 下面我有一个Person接口,一个实现类和一个驱动程序类,它使用一个名称初始化Person并再次输出它.使用的优点是什么
Person person = new PersonImpl();
Run Code Online (Sandbox Code Playgroud)
代替
PersonImpl person = new PersonImpl();
Run Code Online (Sandbox Code Playgroud)
该接口应该隐藏实现?这是使用接口的正确方法吗?
public class Driver {
public static void main(String [] args)
{
Person person = new PersonImpl();
person.setName("test name");
System.out.println("Name is "+person.getName());
}
}
public interface Person {
public void setName(String name);
public String getName();
}
public class PersonImpl implements Person{
private String name;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud) 我是jQuery的新手,我只是试图将一个布尔值传递给一个函数.我尝试了各种修改,但仍然无法正常工作?
我期待警报被解雇
isTrue(true);
function isTrue(boolean isNot){
if(isNot){
alert('true');
}
}
Run Code Online (Sandbox Code Playgroud) 我的解释_._1是:
_= wildcard parameter
_1=方法参数列表中的第一个参数但是当.它与它表示什么一起使用时?
这是它的用法:
.toList.sortWith(_._1 < _._1)
Run Code Online (Sandbox Code Playgroud)
对于这个声明:
_++_
Run Code Online (Sandbox Code Playgroud)
我迷路了.是以某种方式连接两个通配符参数?这是它的用法:
.reduce(_++_)
Run Code Online (Sandbox Code Playgroud)
如果上面的代码可以变得更加冗长并删除任何含义,我会特别感兴趣,这样我才能更好地理解它?
以下scala声明的含义是什么:
type MyType = Int => Boolean
Run Code Online (Sandbox Code Playgroud)
这是我的理解:
我正在声明一个新类型'MyType',但高阶函数'Int => Boolean'的意思是什么
我遇到了一个扩展Exception的类:
public class MyException extends Exception
{
public MyException()
{
super();
}
public MyException(final String argMessage, final Throwable argCause)
{
super(argMessage, argCause);
}
public MyException(final String argMessage)
{
super(argMessage);
}
public MyException(final Throwable argCause)
{
super(argCause);
}
}
Run Code Online (Sandbox Code Playgroud)
这种方式不是毫无意义的扩展异常,因为所有重写的构造函数都只是调用超类Exception吗?
我是否需要以下弹簧上下文文件中的所有以下xmlns和xsi:schemaLocation?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<context:annotation-config />
<bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean id = "controller" class="simpleController"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
因为我只是定义一个bean类只是使用
xmlns="http://www.springframework.org/schema/beans" and its corresponding schema location enough ?
Run Code Online (Sandbox Code Playgroud)
我不需要其他定义?如果不是,我什么时候需要使用这些定义?
我有一个java maven项目,我想用scala进行单元测试.但是我如何在一个Eclipse项目中混合使用java和scala代码,因为java和scala使用自己的编译器.因为这个scala代码不会在Eclipse中编译,因为java编译器需要java语法.
目前我的项目基于Eclipse,它们是基于Java的项目.他们是否需要转换为不同的项目类型,如scala?