我最近把我的所有代码都手动导入到BlueJ的eclipse项目中,然后我开始使用设置"运行配置",最后认为我是免费的.然后我运行了代码,我收到了这个错误
java.lang.NoSuchMethodError: main
Exception in thread "main"
Run Code Online (Sandbox Code Playgroud)
所以我想我必须添加一个主方法(我从来没有在BlueJ中这样做,为什么?).所以我这样做只是调用了构造函数方法(在BlueJ中我只是创建一个新对象,JFrame会显示).所以我这样做了,同样的错误.尝试不同的事情后(例如将构造函数中的代码移动到不同的方法等).我把它放在主要方法中:
public void main(String[] args)
{
System.out.println("Hello, this is main why won't Java find this.");
}
Run Code Online (Sandbox Code Playgroud)
之后我仍然遇到了同样的错误,所以我决定将它添加到我的所有类中,以确保它没有使用另一个类作为主类.仍然是同样的错误,所以我想知道你是否有人遇到过这个问题.我也搜索了谷歌,我发现的所有问题都是private类等问题,而且感觉我所有的课程都是public(嘿,我来自Python :)).我知道那不是问题.请帮忙 :)
我的运行配置的图片

警告:长
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class AppFrame extends JFrame
{
public String status = "Status:";// Status of Applet
public int paint_count = 1;// Number of times applet has been painted
public int[] mousePos = {-1, -1};// Stores Mouse's Last Clicked X and Y Cordinates
public …Run Code Online (Sandbox Code Playgroud) 我们需要存储最多 2^38 的整数值。有什么理由使用decimal(12,0)还是应该使用bigint?
我正在编写一个小型/ beta测试程序,该程序将用于我更大的项目程序中.它向用户请求输入文件名(IE data.txt)并创建名为filename.out(IE data.out)的输出文件.我试过一个简单的outFile <<"text here"; 尝试一下,但它不会创建输出文件.我确定我在这里搞砸了一些简单的东西,但我无法弄清楚是什么.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
//Global variables
ifstream inFile;
ofstream outFile;
void main()
{
// Requests user for input filename
string inputFile;
cout << "Enter File Name: ";
cin >> inputFile;
string outputFile = inputFile.substr(0, inputFile.find_last_of('.')) + ".out";
// Opens both inputFile and outputFile
inFile.open(inputFile.c_str(), ios::in);
outFile.open(outputFile.c_str(), ios::in);
// Checks for input file
if (!inFile)
{
cout << "Unable to open file" << endl;
exit(1);
}
outFile << "Hello …Run Code Online (Sandbox Code Playgroud) 我有一些我不想处理的log.debugs()(因为它们很重)除非应用程序当前处于调试模式(非生产).
有没有办法检查grails应用程序当前是否处于调试模式/开发模式?
我和我的朋友正在进行一些基本的Ruby练习以了解语言,我们遇到了一个我们无法理解的有趣行为.基本上,我们创建的tree数据类型只有一个类node,它只包含一个值和一个零或更多的数组nodes.我们正在使用rspec的autospec测试运行器.有一次,我们开始编写测试以禁止无限递归(循环树结构).
这是我们的测试:
it "breaks on a circular reference, which we will fix later" do
tree1 = Node.new 1
tree2 = Node.new 1
tree2.add_child tree1
tree1.add_child tree2
(tree1 == tree2).should be_false
end
Run Code Online (Sandbox Code Playgroud)
这是Node类:
class Node
attr_accessor :value
attr_reader :nodes
def initialize initial_value = nil
@value = initial_value
@nodes = []
end
def add_child child
@nodes.push child
@nodes.sort! { |node1, node2| node1.value <=> node2.value }
end
def == node
return (@value == node.value) && …Run Code Online (Sandbox Code Playgroud) 我一直在研究D编程语言,对于已经精通C++的人来说,看起来很有趣.
我可以使用D编程到作为C接口的Java Native Interface吗?
我试图使用OpenGL使其成为一个光滑的多边形,但它没有做任何事情.有人可以解释一下我做错了什么吗?
glColor4ub(r, g, b, a);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glBegin(GL_QUADS);
glVertex2i(x, y);
glVertex2i(x1, y1);
glVertex2i(x2, y2);
glVertex2i(x3, y3);
glEnd();
glDisable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我有以下代码来添加叠加
myMapView.getOverlays().add(sites);
myMapView.invalidate();
Run Code Online (Sandbox Code Playgroud)
我还有以下删除代码,其中sites是一个全局变量.
if (sites != null) {
// myMapView.getOverlays().clear();
myMapView.getOverlays().remove(sites);
myMapView.invalidate();
sites = null;
}
Run Code Online (Sandbox Code Playgroud)
有时我会留下重复,所以想要从地图中删除所有叠加层的方法,这可能吗?
有没有办法用python以彩色方式打印字符串?
例如,我可以将一些字符串红色或某些东西打印到控制台吗?我使用的是Mac OS X.
String lower = Name.toLowerCase();
int a = Name.indexOf(" ",0);
String first = lower.substring(0, a);
String last = lower.substring(a+1);
char f = first.charAt(0);
char l = last.charAt(0);
System.out.println(l);
Run Code Online (Sandbox Code Playgroud)
如何将F和L变量转换为大写.