试图在Mountain Lion上安装nokogiri.我使用的是ruby 1.8.7,但刚刚升级到1.9.3但它阻止了捆绑安装工作.
顺便说一句,我可以通过卸载ruby 1.9.3并恢复到1.8.7来解决这个问题.然而,这显然是一个次优的解决方案,因为我不想在剩下的时间里坚持1.8.7 ...
Users-MacBook-Pro:sample_app user$ ls
Gemfile app doc script
Gemfile.lock config lib spec
README.md config.ru log tmp
Rakefile db public vendor
Ravins-MacBook-Pro:sample_app user$ bundle
Fetching gem metadata from https://rubygems.org/.......
/Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.1/lib/bundler.rb:263: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.8)
Using builder (3.0.3)
Using activemodel (3.2.8)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1) …Run Code Online (Sandbox Code Playgroud) 所以我得到的错误是:"不能参考以不同方法定义的内部空间内的非最终变量角色".我希望能够将字符串roletype设置为该Dropdown中选择的任何get.如果不是我在下面尝试的方式,我怎么能这样做,或者我只是在我正在尝试的代码中犯了一些愚蠢的错误?
谢谢,拉文
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.*;
import javax.swing.event.*;
public class Funclass extends JFrame {
FlowLayout layout = new FlowLayout();
String[] skillz = {"Analytical", "Numerical", "Leadership",
"Communication", "Organisation", "Interpersonal"};
String[] rolez = {"Developer", "Sales", "Marketing"};
String[] Industries = {"Consulting", "Tech"};
String R1, R2, R3, R4, roletype;
public Funclass() {
super("Input Interface");
setLayout(layout);
JTextField Company = new JTextField("Company Name");
JComboBox TYPE = new JComboBox(Industries);
JList skills = new JList(skillz);
JComboBox role = new JComboBox(rolez);
skills.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(TYPE); …Run Code Online (Sandbox Code Playgroud) Java新手 - 只是试图掌握它.该程序执行如下:
What's your age?23
23
What's your name?Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at king.getName(king.java:25)
at king.main(king.java:9)
Run Code Online (Sandbox Code Playgroud)
它试图运行的代码如下:
import java.util.*;
public class king {
public static void main(String[] args){
System.out.println(getAge());
System.out.println(getName());
}
public static int getAge(){
System.out.print("What's your age?");
Scanner scanner = new Scanner(System.in);
String age = scanner.next();
scanner.close();
int numberAge = Integer.parseInt(age);
return numberAge;
}
public static String getName(){
System.out.print("What's your name?");
Scanner newScanner = new Scanner(System.in);
String name = newScanner.next();
newScanner.close(); …Run Code Online (Sandbox Code Playgroud) 试图设置String变量的代码块似乎出现了问题,因为无论我在运行程序时做什么,对话框总是显示otto.有谁知道我在这里做错了什么?
谢谢,拉文
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class SmallTingz extends JFrame {
private JLabel item1;
private JTextField tf;
private JTextField tf2;
private JTextField tf3;
private JPasswordField pf;
public SmallTingz() {
super("The Title");
setLayout(new FlowLayout());
JTextField tf = new JTextField("Cool Beans");
JTextField tf2 = new JTextField("UnCool Beans");
JTextField tf3 = new JTextField("Hot Beans");
JPasswordField pf = new JPasswordField("password");
add(tf);
add(tf2);
add(tf3);
add(pf);
thehandler handler = new thehandler();
tf.addActionListener(handler);
tf2.addActionListener(handler); …Run Code Online (Sandbox Code Playgroud) 我收到一个错误,说这些方法不适用于Graphics类型?我不完全了解这里发生了什么 - 有人能解释我做错了什么以及为什么错了?谢谢,
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Peach extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
this.setBackground(Color.WHITE);
g.setColor(Color.BLUE);
g.fillRect(25, 25, 100, 30);
g.setColor(new Color(190, 82, 45));
g.fillRect(25, 65, 100, 30);
g.setColor(Color.RED);
g.drawString("this is text", 25, 100);
}
}
Run Code Online (Sandbox Code Playgroud) 由于某种原因,我得到的模块对象在此代码上不可调用错误.我真的不明白为什么?什么事情发生,我该如何解决?:(
import time
start_time = time.time()
name = raw_input('What is your name')
end_time = time.time()
total_time=end_time-start_time
print total_time
Run Code Online (Sandbox Code Playgroud)
和追溯:
Traceback (most recent call last):
File "time.py", line 1, in <module>
import time File "/Users/Me/randomcode/time.py", line 2, in <module>
start_time = time.time()
TypeError: 'module' object is not callable
Run Code Online (Sandbox Code Playgroud) 当我在另一个类中调用displayTime12hrclock方法时,它拒绝打印出AM或PM.我无法理解为什么.
public class Tuna {
private int hour;
private int minute;
private int second;
public void setTime(int h, int m, int s){
hour = h;
minute = m;
second = s;
hour = ((h>= 0 && h <=24 ? h:0));
minute = ((m>= 0 && m <=60 ? m:0));
second = ((s>= 0 && s <=60 ? s:0));
}
public String displayTime(){
return String.format("%02d:%02d:%02d", hour,minute,second);
}
public String displayTime12hrclock(){
return String.format("%d:%02d:%02d", ((hour==0 || hour ==12)?12:hour%12), minute, second, (hour >=12)? "AM":"PM"); …Run Code Online (Sandbox Code Playgroud) 试图从一组数据中创建一个数据透视表。通常它第一次运行良好,但是如果您尝试第二次运行它,它会抛出“无效的过程调用或参数”,并且当您单击调试时,代码将以下突出显示为问题。更改数据透视表的名称无济于事。工作表 2 存在并填充了数据。Data-Summary 表也存在并且完全是空的
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet2!R1C1:R1064C4", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="Data-Summary!R5C1", TableName:="PivotTable4", _
DefaultVersion:=xlPivotTableVersion
Run Code Online (Sandbox Code Playgroud)
整个代码如下:
Sub Macro1()
'
' Macro1 Macro
'
'
Columns("A:D").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet2!R1C1:R1064C4", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="Data-Summary!R5C1", TableName:="PivotTable15", _
DefaultVersion:=xlPivotTableVersion14
Sheets("Data-Summary").Select
Cells(5, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Site")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Channel")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Cost"), "Count of Cost", xlCount
ActiveSheet.PivotTables("PivotTable3").PivotFields("Count of Cost"). _
Orientation = xlHidden
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Revenue"), "Count …Run Code Online (Sandbox Code Playgroud)