如何将链接写入javadocs?
目前,我有类似的东西:
{@link java.lang.Math#sqrt(double) Math.sqrt}
Run Code Online (Sandbox Code Playgroud)
生成Math.sqrt应该链接到java.lang.Math.sqrt(double)API 的文本,但是,它所做的只是生成文本,没有链接.
如何计算BigDecimal的对数?有谁知道我可以使用的任何算法?
到目前为止,我的谷歌搜索已经提出了(无用的)只需转换为双精度并使用Math.log的想法.
我将提供所需答案的精确度.
编辑:任何基地都会这样做.如果它在基数x中更容易,我会这样做.
有没有办法找到运行我的Java程序的控制台的宽度?
如果可能的话,我希望这是跨平台的......
我不想改变缓冲区或窗口的宽度,我只是想知道它的宽度,所以我可以正确地格式化正在打印到屏幕的文本.
您总是在类中实现哪些方法和接口?
你总是重写equals()吗?如果你这样做,你也做hashcode()吗?的toString()?你是否习惯于实现Comparable接口?
我刚刚编写了一些代码,我需要实现compareTo()并覆盖equals()以使我的程序以理智的方式工作; 我现在开始看到各处使用这些的方法......
你们都在想什么?
我正在寻找一个我在以前的工作站上安装的正则表达式测试程序,我现在无法在任何地方找到它.
这是针对特定于java的正则表达式,所以我很确定它是用Java编写的.顶部有一些选项卡,其中一个是API中Pattern类的不同正则表达式的解释.
顶部文本框用于输入文本,中间文本框用于正则表达式,底部文本框用于显示匹配项.
我知道继续下去并不多,但是有人认出它吗?
我可以使用运行时以 std::format 定义的格式字符串吗?
这似乎是在说你不能;所有格式字符串都是编译时的事情。我可以发誓我是在几个月前才这么做的,也许是在标准回归之前。
#include <iostream>
#include <string>
#include <format>
std::string centre(std::string& string, const int width, const char fillchar = ' '){
if (width <= string.size())
return string;
string = std::format("|{0:{1}^{2}}|", string, fillchar, width); //line 25
return string;
}
int main() {
std::cout << centre(s, 10, '*');
}
Run Code Online (Sandbox Code Playgroud)
在构建时,我收到错误
string.cpp(25,24): 错误 C7595: 'std::_Basic_format_string<char,row::string::str &,const size_t &,const char &>::_Basic_format_string': 对立即函数的调用不是常量表达
是否可以创建需要外部依赖项的JAR文件而不在JAR文件中包含这些依赖项?
我的google-fu未能给我答案; 我找到的所有内容都显示了如何将它们包含在JAR文件中,但是不要将它放在清单文件中说"我还没有它们,查看用户的类路径".我假设在用户的类路径上正确安装和配置了依赖项.
就我而言,我的依赖项是Apache Commons CLI和Math.
编辑:在我的JAR文件中,我有Main.class.
我的清单文件如下:
Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: Main
Run Code Online (Sandbox Code Playgroud)
我的CLASSPATH看起来像
.;C:\Program Files\Java\jre1.6.0_06\lib\ext\QTJava.zip;C:\java_lib\commons-cli-1.2.jar;C:\java_lib\commons-math-2.0\commons-math-2.0.jar
Run Code Online (Sandbox Code Playgroud)
如果我在JAR中包含依赖/lib项并将该行添加Class-Path: lib/commons-math-2.0.jar lib/commons-cli-1.2.jar到清单中,那么它确实有效.
我已经尝试添加Class-Path: commons-math-2.0.jar commons-cli-1.2.jar到清单而不包括JAR中的文件,只是为了看看是否可行,但事实并非如此.
如何在Python脚本中查看调用哪些函数和所有变量值?
我刚刚发现了Python的不确定性包,我想弄清楚它是如何工作的,所以我可以向老板解释一下.
基本上,我看不出实际计算的不确定性.这可能是因为我不知道Python是如何工作的.
对于初学者,我怎样才能看出如何c计算?
import uncertainties
from uncertainties import ufloat
a = ufloat(1,3)
b = ufloat(2,4)
c = a + b # How does this work??
print c
Run Code Online (Sandbox Code Playgroud) 使用Julia,我已经定义了一个9x10的零矩阵,我试图改变一个条目,但是我得到了错误 'setindex!' has no method matching setindex!(::Float64, ::Float64, ::Int64)
我的代码是:
m = zeros(9,10)
m[1][1] = 1.0
Run Code Online (Sandbox Code Playgroud)
错误指向第二行.typeof(m)是一个Array{Float64,2},据我所知是可变的.
我在这做错了什么?
在这段代码中,为什么我的数组不是按照我想要的那样初始化的?for-each循环是不是设计成这样做的,还是我只是没有正确使用它?
int[] array = new int[5];
//initialise array -> Doesn't work! Array still full of 0's
for(int i : array)
i = 24;
Run Code Online (Sandbox Code Playgroud) 只是想知道你是否能够帮我解决我的问题.这可能是因为我不知道要搜索的正确关键字.
这不是家庭作业,只是匿名......
我有一个接口和一堆实现类:
interface Fruit
Banana implements Fruit
Apple implements Fruit
....
Run Code Online (Sandbox Code Playgroud)
我有一个水果实用程序类.在这是一个方法,采取任何种类的水果切片.
public static Fruit[] slice(Fruit f, int pieces)
Run Code Online (Sandbox Code Playgroud)
如何声明Fruit数组与我传递给方法的Fruit类型相同?
即我如何自动化:
Fruit[] a = new Apple[pieces];
Run Code Online (Sandbox Code Playgroud)
如果我给它一个苹果?
.
编辑:澄清
我会有这样的代码:
Fruit a = new Apple();
Fruit b = new Banana();
Fruit[] slices1 = FruitUtil.slice(a, 3); //slices1 should be an Apple
Fruit[] slices2 = FruitUtil.slice(b, 3); //slices2 should be a Banana
Fruit newApple = FruitUtil.copy(a); //newApple should be an Apple
Run Code Online (Sandbox Code Playgroud)
我如何编写切片(Fruit f,int slice)或copy(Fruit f)方法,以便创建与我在参数中传递的相同类型的Fruit(不必为每种类型覆盖方法,或者执行instanceof检查) )
我在使用Python从文件导入数据时遇到了一些问题.我是Python的新手,所以我的错误可能很简单.
我正在阅读3列,制表符分隔的文本文件,没有标题.我正在使用三个不同的数据文件创建3个数据文件实例.
我可以看到每个对象都引用了不同的内存位置,因此它们是分开的.
当我查看存储在每个实例中的数据时,每个实例都具有相同的内容,包括彼此附加的三个数据文件.
我做错了什么?
读入数据的类是:
class Minimal:
def __init__(self, data=[]):
self.data = data
def readFile(self, filename):
f = open(filename, 'r')
for line in f:
line = line.strip()
columns = line.split()
#creates a list of angle, intensity and error and appends it to the diffraction pattern
self.data.append( [float(columns[0]), float(columns[1]), float(columns[2])] )
f.close()
def printData(self):
for dataPoint in self.data:
print str(dataPoint)
Run Code Online (Sandbox Code Playgroud)
数据文件看起来像:
1 4 2
2 5 2.3
3 4 2
4 6 2.5
5 8 5
6 10 3
Run Code Online (Sandbox Code Playgroud)
我用来实际创建Minimal实例的程序是: …
我正在用来PySimpleGUI创建一个文本输出框。
打开程序时,我希望输出在按下任何按钮之前显示一些默认文本。
我怎样才能让这种情况发生?window.Read()等待按下按钮。window.refresh()似乎并没有将文本强制显示到窗口。
import PySimpleGUI as sg
initialString = "I want this text to display on window opening."
def gui2():
layout = [
[sg.Output(size=(90,20), background_color='black', text_color='white')],
[sg.Button('Do things'), sg.Button('Exit')]
]
window = sg.Window("Funny Title", layout)
#window.read() #I need to press a button before the text will display
#window.refresh() #doesn't refresh the output
print(initialString)
#window.refresh() #doesn't refresh the output
while True:
event, values = window.read()
if event in (sg.WIN_CLOSED, 'Exit'):
break
elif event == 'Do …Run Code Online (Sandbox Code Playgroud)