我想在带有换行符的函数中获得尽可能多的星星。但我无法通过换行来获取它们。
public class prac11 {
public static void main(String[] args) {
//printStars(1);
printStars(2);
printStars(3);
}
public static void printStars(int x) {
int i=1;
while(i<=x) {
System.out.print("*");
i++;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图使用maven依赖插件解包jar文件.但我只想在jar文件中有一个文件,并且想要排除jar内的META-INF目录.我该怎么做?
这是我到目前为止:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<type>jar</type>
<outputDirectory>${project.basedir}/src/test/</outputDirectory>
<excludes>META-INF</excludes>
</artifactItem>
</artifactItems>
<excludes>META-INF</excludes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我在 url 上与邮递员进行 api 调用:
https://cex.io/api/order_book/BTC/USD
Run Code Online (Sandbox Code Playgroud)
简单的 GET 没有标题没有参数没有什么。但与 java 相同:
RestTemplate rt = new RestTemplate();
rt.getForObject("https://cex.io/api/order_book/BTC/USD", String.class);
Run Code Online (Sandbox Code Playgroud)
让我 403. 问题出在哪里?
我对 Java 中的数据类型感到困惑。我在 Internet 上看到了很多将 Java 中的数据类型表示为树的图像,这让我对过去的想法感到犹豫。这些树的示例如下所示:
因此,在另一篇 SO帖子中,Buhake Sindi 指出:
Boolean 是原始类型的包装器
按照之前 Java 中数据类型的树表示,我的问题是:
我的问题是从 Temporal 接口中找到一个有用的方法。具体来说,我想从一个实现 Temporal 接口的对象中获取年份。接口的所有方法都只是从对象中添加或删除,但是,我只想获取时间本身的年份。
class Dog{
int height;
int weight;
String name;
}
public class DogTest {
public static void main(String[] args) {
Dog one = new Dog();
one.height=4;
one.name="fudo";
one.weight =2;
Dog two = new Dog();
two.height=4;
two.name="fudo";
two.weight =2;
if (one.equals(two)){
System.out.println("True");
}
else{
System.out.println("False");
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么输出"假"?如果Java默认情况下"所有对象即使它们具有相同的值也不相等"那么我如何"说服"Java这两个对象实际上是相等的?好吧,即使两只狗有相同的名字,身高,体重也可以是dalmatiner而另一只是斗牛犬,即使它们是相同的"种族",在性质上,它们总是彼此不同.
PS:我理解通过说if(one == two){}我们比较它们是否都引用堆上的相同对象,字符串上的.equals比较它们是否具有相同顺序的相同字符.
我在有效的Java中经历了“相等”方法的概念,然后在下面找到了以下代码:
@Override
public boolean equals(Object o) {
if (o instanceof CaseInsensitiveString)
return s.equalsIgnoreCase(((CaseInsensitiveString) o).s);
if (o instanceof String) // One-way interoperability!
return s.equalsIgnoreCase((String) o);
return false;
}
Run Code Online (Sandbox Code Playgroud)
在这里,我无法获得特定的行((CaseInsensitiveString) o).s
。现在,我从这段代码中了解到的是对象“ o”被类型转换为CaseInsensitiveString
Class。现在是什么).s
意思。
我正在用 java 编写一个测试程序,并希望并行化一个列表对象。
SparkSession spark = SparkSession
.builder()
.master("local[*]")
.appName("JavaWordCount")
.getOrCreate();
System.out.println("hello");
List<String> l = new ArrayList<>(5);
l.add("view.txt");
spark.sparkContext().parallelize(l,1,"test");
Run Code Online (Sandbox Code Playgroud)
SparkContext 类型中的 parallelize(Seq, int, ClassTag) 方法不适用于参数 (List, int, String)
我不确定第三个参数是什么 - class Tag
我想编写一个 Java 代码,以便对以“Foo”开头的任何单词执行某些操作,对所有以“Bar”开头的单词执行其他操作。
for(String str: stringList) {
switch (str) {
case Foo*: // do something. then break.
case Bar*: // do something else. break.
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我如何在 java 中进行这个正则表达式匹配?
在 Flutter 中聚焦时如何在 TextFormField 中添加阴影?我希望该字段具有以下外观:
到目前为止,我设法在对焦时应用了边框,但我没有看到任何应用阴影的选项:
TextFormField(
decoration: InputDecoration(
fillColor: Colors.white,
hoverColor: Colors.white,
filled: true,
enabledBorder: OutlineInputBorder(borderSide: BorderSide.none),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey, width: 1))),
);
Run Code Online (Sandbox Code Playgroud)
关于如何获得这种效果的任何想法?