它们是由编译过程的不同阶段产生的吗?或者它们只是同一个东西的不同名称?
compiler-construction compiler-theory terminology abstract-syntax-tree parse-tree
我正在遵循Artifactory 1分钟的设置.我在我的localhost上运行了Artifactory,现在我正在尝试将它与Intellij/Gradle集成.
在Web应用程序artifactory的给出了一个gradle.properties和build.gradle文件,所以我想先从增加这些对我的IntelliJ项目.但是,我不知道把gradle.properties文件放在哪里.
我尝试复制gradle.properties内容(键=值对)gradle/wrapper/gradle-wrapper.properties,遗憾的是这样做不会使build.gradle文件中的密钥可访问.有任何想法吗?
我需要更改默认的Eclipse WTP"Web Resources"动态文件夹.目前它指向WebContent,我需要指向src\main\webapp.
我试图了解工厂模式.如果有很多实现,那么我的工厂模式将有很多if else或switch情况.每次我介绍一个新的实现时,我都应该更改我的工厂代码
如下面的例子中如果让代表或切换案例,如果许多动物实现宠物界面我的工厂会如同许多动物实施宠物界面那么假设狗鸭正在实施宠物界面.有没有办法通过带来更多动态方法来解决这个问题?
package com.javapapers.sample.designpattern.factorymethod;
//Factory method pattern implementation that instantiates objects based on logic
public class PetFactory {
public Pet getPet(String petType) {
Pet pet = null;
// based on logic factory instantiates an object
if ("bark".equals(petType))
pet = new Dog();
else if ("quack".equals(petType))
pet = new Duck();
return pet;
}
Run Code Online (Sandbox Code Playgroud)
如果动物长大
if ("bark".equals(petType))
pet = new Dog();
else if ("quack".equals(petType))
pet = new Duck();
else if ("mno".equals(petType))
pet = new MNO();
else if ("jkl".equals(petType))
pet = new JKL(); …Run Code Online (Sandbox Code Playgroud) 这被认为非常简单,但我无法从键盘读取连续输入.
这是代码:
#include <string.h>
#include <stdio.h>
int main()
{
char string[200];
char character;
printf ("write something: ");
scanf ("%s", string);
printf ("%s", string);
printf ("\nwrite a character: ");
scanf ("%c", &character);
printf ("\nCharacter %c Correspondent number: %d\n", character, character);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
怎么了
当我输入一个字符串(例如:计算机)时,程序会读取换行符('\n')并将其放入character.以下是显示的外观:
write something: computer
computer
Character:
Correspondent number: 10
Run Code Online (Sandbox Code Playgroud)
此外,该程序不适用于包含多个单词的字符串.我怎么能克服这些问题?
假设我的代码中经常重复以下模式:
class A<T> {
@Inject
public A(List<T> list) {
// code
}
}
Run Code Online (Sandbox Code Playgroud)
我要绑定全部 List<T>到ArrayList<T>.我知道我可以使用TypeLiterals来绑定一个显式的原始类型,例如List<String>,但是无论如何都要为所有类型执行此操作?
基本上,这段代码不应该失败,因为我没有明确地绑定List:
injector.getInstance(new Key<A<Integer>>(){});
Run Code Online (Sandbox Code Playgroud) 这是一个重现问题的示例脚本:
例子.zsh
zmodules=(foo bar/baz)
local zmodule
for zmodule (${zmodules}); do
local zurl zname
zname=${zmodule##*/}
case ${#zmodule//[^\/]/} in
0) zurl="https://github.com/foo/${zmodule}" ;;
1) zurl="https://github.com/${zmodule}" ;;
esac
print "${zurl} ${zname}"
done
Run Code Online (Sandbox Code Playgroud)
当前运行脚本的结果:
$ source ./example.zsh 2>/dev/null
zmodule=bar/baz
zurl=https://github.com/bar/baz
zname=baz
https://github.com/foo/foo foo
zurl=https://github.com/foo/foo
zname=foo
https://github.com/bar/baz baz
Run Code Online (Sandbox Code Playgroud)
预期结果:
$ source ./example.zsh 2>/dev/null
https://github.com/foo/foo foo
https://github.com/bar/baz baz
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么?
编辑:我想我明白了:local只能在函数内部使用。但是为什么在我声明局部变量时仍然打印赋值?
我有这个JSON对象:
{
"1":{
"id_module":"f83d6101cc",
"adresse_mac":"00:6A:8E:16:C6:26",
"mot_de_passe":"mp0001","name":"a"
},
"2":{
"id_module":"64eae5403b",
"adresse_mac":"00:6A:8E:16:C6:26",
"mot_de_passe":"mp0002",
"name":"a"
}
}
Run Code Online (Sandbox Code Playgroud)
而且我想解析,并获得字符串id_module,adresse_mac,mot_de_passe和name每个事物的1和2.
所以我做了这个,但它不起作用:
TextView txt1=(TextView) findViewById(R.id.textView);
String ajout1 = "http://";
JSONObject json = null;
String str = "1";
HttpResponse response;
HttpClient myClient = new DefaultHttpClient();
HttpPost myConnection = new HttpPost(ajout1);
try {
response = myClient.execute(myConnection);
str = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
JSONObject jsonObject = new JSONObject(str); …Run Code Online (Sandbox Code Playgroud) 我使用JpaRepository并JpaSpecificationExecutor从春季的数据,我有一个问题排序的方法findAll(specification, pageable, sort)
我想通过主repo类的嵌套属性对规范的结果进行排序.这是我的情况:
主要课程
class Foo {
//other properties
@OneToMany(mappedBy="foo")
private Set<Bar> bars;
}
Run Code Online (Sandbox Code Playgroud)
订购类
class Bar {
@ManyToOne
@JoinColumn(name="fooId")
private Foo foo;
//I WANT TO SORT BY THIS FIELD
@Column
private Date date;
}
Run Code Online (Sandbox Code Playgroud)
这是我的回购
interface FooRepo extends JpaRepository<Foo , Long>,
JpaSpecificationExecutor<Foo>{
//just jparepo methods
}
Run Code Online (Sandbox Code Playgroud)
这就是我正在尝试订购这个结果
void anymethod(){
Sort sort = new Sort(Bar_.date.getName());
PageRequest pr = new PageRequest(anyPage, anyMaxResultsNum, sort);
repository.findAll(anySpecification, pr);
}
Run Code Online (Sandbox Code Playgroud)
当我运行这个我得到"PropertyReferenceException:找不到类型Foo的属性日期!"
我怎样才能做到这一点?
我正在翻译我的应用程序.因此,我需要将所有文本都放到字符串中.翻译工作正常,除了两个字符串.他们只显示数字.我尝试将不起作用的字符串更改为在其他textview中工作的字符串,但这不起作用.为什么我的字符串显示为数字.
这是我的java代码:
TextView repetitionsRemaining = (TextView)findViewById(R.id.repetitionsRemaining);
repetitionsRemaining.setText(R.string.repetitions_remaining + ":" + " "
+ currentRepititions + "/" + repetitionsTotal);
Run Code Online (Sandbox Code Playgroud)
这是我的string.xml代码:
<string name="repetitions_remaining">Repetitions remaining</string>
Run Code Online (Sandbox Code Playgroud)
java ×5
android ×2
string ×2
artifactory ×1
c ×1
char ×1
eclipse ×1
eclipse-wtp ×1
gradle ×1
guice ×1
json ×1
parse-tree ×1
shell ×1
spring ×1
spring-data ×1
terminology ×1
zsh ×1