Many years ago when I was at uni they said to put a capital i (I) in front of interfaces. Is this still a convention because I see many interfaces that do not follow this.
I have one class that declares an enumeration type as:
public enum HOME_LOAN_TERMS {FIFTEEN_YEAR, THIRTY_YEAR};
Is this type usable in another class? I'm basically trying to complete a homework assignment where we have two types of loans, and one loanManager class. When I try to use the HOME_LOAN_TERMS.THIRTY_YEAR in my loanManager class that does not extend or implement the loan class, I get an error saying it 'cannot find symbol HOME_LOAN_TERMS.' So I did not know if my loanManager class needed to implement the two different loan classes. Thanks.
Hi,
I need to decide which configuration framework to use. At the moment I am thinking between using properties files and XML files. My configuration needs to have some primitive grouping, e.g. in XML format would be something like:
<configuration>
<group name="abc">
<param1>value1</param1>
<param2>value2</param2>
</group>
<group name="def">
<param3>value3</param3>
<param4>value4</param4>
</group>
</configuration>
or a properties file (something similar to log4j.properties):
group.abc.param1 = value1
group.abc.param2 = value2
group.def.param3 = value3
group.def.param4 = value4
I need bi-directional (read and write) configuration library/framework. Nice feature would be - that I could read out somehow different configuration groups as different objects, so I could later pass them to different places, e.g. - reading everything what belongs to group "abc" as one object and "def" as another. If that is not possible I can always split single configuration object into smaller ones myself in the application initialization part of course.
Which framework would best fit for me?
I am trying to program a game in which I have a Table class and each person sitting at the table is a separate thread. The game involves the people passing tokens around and then stopping when the party chime sounds.
how do i program the run() method so that once I start the person threads, they do not die and are alive until the end of the game
One solution that I tried was having a while (true) {} loop in the run() method but that increases my CPU utilization to around 60-70 percent. Is there a better method?
Can anyone explain:
Why the two patterns used below give different results? (answered below)
Why the 2nd example gives a group count of 1 but says the start
and end of group 1 is -1?
public void testGroups() throws Exception
{
String TEST_STRING = "After Yes is group 1 End";
{
Pattern p;
Matcher m;
String pattern="(?:Yes|No)(.*)End";
p=Pattern.compile(pattern);
m=p.matcher(TEST_STRING);
boolean f=m.find();
int count=m.groupCount();
int start=m.start(1);
int end=m.end(1);
System.out.println("Pattern=" + pattern + "\t Found=" + f + " Group count=" + count +
" Start of group 1=" + start + " End of group 1=" + end );
}
{
Pattern p;
Matcher m;
String pattern="(?:Yes)|(?:No)(.*)End";
p=Pattern.compile(pattern);
m=p.matcher(TEST_STRING);
boolean f=m.find();
int count=m.groupCount();
int start=m.start(1);
int end=m.end(1);
System.out.println("Pattern=" + pattern + "\t Found=" + f + " Group count=" + count +
" Start of group 1=" + start + " End of group 1=" + end );
}
}
Which gives the following output:
Pattern=(?:Yes|No)(.*)End Found=true Group count=1 Start of group 1=9 End of group 1=21
Pattern=(?:Yes)|(?:No)(.*)End Found=true Group count=1 Start of group 1=-1 End of group 1=-1
I have a main class in a program that launches another class that handles all the GUI stuff.
In the GUI, i have a button that i need to attach an ActionListener to.
The only problem is, the code to be executed needs to reside within the main class.
How can i get the ActionPerformed() method to execute in the main class when a button is clicked elsewhere?
I am looking for something very close to an application server with these features:
it should handle a series of threads/daemons, allowing the user to start-stop-reload each one without affecting the others
it should keep libraries separated between different threads/daemons
it should allow to share some libraries
Currently we have some legacy code reinventing the wheel... and not a perflectly round-shaped one at that!
I thought to use Tomcat, but I don't need a web server, except maybe for the simple backoffice user interface (/manager/html).
Any suggestion? Is there a non-web application server, or is there a better alternative to Tomcat (more lightweight, for example, or easier to configure)? Thanks in advance.
Assign the following 25 scores to a one dimensional int array called "temp"
34,24,78,65,45,100,90,97,56,89,78,98,74,90,98,24,45,76,89,54,12,20,22,55,66
Move the scores to a 2 dimensional int array called "scores" row wise
-- meaning the first 5 scores go into row 0 etc
Hello,
I configure my web application to use SSL using my own self signed certificate. Everything is working fine but here my whole site is https now as i used :-
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
However, i only want my login page to use SSL and not complete site. What changes do i need to make in my application?
Thanks in advance :)
private static char[] quicksort (char[] array , int left , int right) {
if (left < right) {
int p = partition(array , left, right);
quicksort(array, left, p - 1 );
quicksort(array, p + 1 , right);
}
for (char i : array)
System.out.print(i + ” ”);
System.out.println();
return array;
}
private static int partition(char[] a, int left, int right) {
char p = a[left];
int l = left + 1, r = right;
while (l < r) {
while (l < right && a[l] < p) l++;
while (r > left && a[r] >= p) r--;
if (l < r) {
char temp = a[l];
a[l] = a[r];
a[r] = temp;
}
}
a[left] = a[r];
a[r] = p;
return r;
}
}
hi guys just a quick question regarding the above coding, i know that the above coding returns the following
B I G C O M P U T E R
B C E G I M P U T O R
B C E G I M P U T O R
B C E G I M P U T O R
B C E G I M P U T O R
B C E G I M O P T U R
B C E G I M O P R T U
B C E G I M O P R T U
B C E G I M O P R T U
B C E G I M O P R T U
B C E G I M O P R T U
B C E G I M O P R T U
B C E G I M O P R T U
when the sequence BIGCOMPUTER is used but my question is can someone explain to me what is happening in the code and how?
i know abit about the quick-sort algorithm but it doesnt seem to be the same in the above example.
This is NOT a question about which is the best framework, etc.
I have never used a mocking framework and I'm a bit puzzled by the idea. How does it know how to create the mock object? Is it done in runtime or generates a file? How do you know its behavior? And most importantly - what is the work flow of using such a framework (what is the step-by-step for creating a test).
Can anyone explain? You can choose whichever framework you like for example, just say what it is.
Can anyone help in architecture design of one of my complex application.
Requirement :
In web based application, we need to generate Excel kind of report as HTML page
and after that we need to perform different kinds of operations like
Add manual rows
Delete rows
Edit rows
adding comments based on each cell
viewing the added comments.
attaching the file based on each cell
viewing the attached file.
Collapsible functionality for some of rows
In the process of design we have come up with DB design and application framework is Spring.
and for Web not yet finalized.
what is the best approach to implement this kind of UI?
--JSF?(keep in mind we need to Excel operations like above mentioned operations)
-- Any reporting tool which will provide editing functionality?
Please suggest me How can we do it? and what is the best technology for it? or is there any reporting tools?
i have defined a variable inside an if statement and I am trying to access it outside of that if statement now. now the error is saying that it cannot find the symbol which is because its being defined as an intance variable, is there a way i can change it so i can access it outside the variable? heres the code
if((e.getSource()==userOrder2)&& (orderType==1))
{
String buyO= userOrder2.getText();
int buyOrder= Integer.parseInt(buyO); //variable im trying to access
}
// trying to use buyOrder in a different if statement
if(orderType==1 && (stockPrice <= buyOrder))
{
orderResult.setText("The Stock" + (stockName2.getText()) + "was bought at" + stockPrice);
}
I have a class Foo which overrides equals() and hashCode() properly.
I would like to also would like to use a HashSet<Foo> to keep track of "canonical values" e.g. I have a class that I would like to write like this, so that if I have two separate objects that are equivalent I can coalesce them into references to the same object:
class Canonicalizer<T>
{
final private Set<T> values = new HashSet<T>();
public T findCanonicalValue(T value)
{
T canonical = this.values.get(value);
if (canonical == null)
{
// not in the set, so put it there for the future
this.values.add(value);
return value;
}
else
{
return canonical;
}
}
}
except that Set doesn't have a "get" method that would return the actual value stored in the set, just the "contains" method that returns true or false. (I guess that it assumes that if you have an object that is equal to a separate object in the set, you don't need to retrieve the one in the set)
Is there a convenient way to do this? The only other thing I can think of is to use a map and a list:
class Canonicalizer<T>
{
// warning: neglects concurrency issues
final private Map<T, Integer> valueIndex = new HashMap<T, Integer>();
final private List<T> values = new ArrayList<T>();
public T findCanonicalValue(T value)
{
Integer i = this.valueIndex.get(value);
if (i == null)
{
// not in the set, so put it there for the future
i = this.values.size();
this.values.add(value);
this.valueIndex.put(value, i);
return value;
}
else
{
// in the set
return this.values.get(i);
}
}
}
Hi,
Is there any keyword or design pattern for doing this?
public abstract class Root
{
public abstract void foo();
}
public abstract class SubClass extends Root
{
public void foo()
{
// Do something
}
}
public class SubberClass extends SubClass
{
// Here is it not necessary to override foo()
// So is there a way to make this necessary?
// A way to obligate the developer make again the override
}
Thanks
I need to be able to call a function, but the function name is stored in a variable, is this possible. e.g:
public void foo ()
{
//code here
}
public void bar ()
{
//code here
}
String functionName = "foo";
// i need to call the function based on what is functionName
Anyhelp would be great, thanks
Based off the one of the demos I have the following code.
Currently what displays in the simulator is just hte contents of the paint function, however the ObjectChoiceField is still selectable if one happens to click in the right location. I would like both the text contents and the paint function contents to appear. Is this possible?
public CityInfoScreen()
{
//invoke the MainScreen constructor
super();
//add a screen title
LabelField title = new LabelField("City Information Kiosk",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
//add a text label
add(new RichTextField("Major U.S. Cities"));
//add a drop-down list with three choices:
//Los Angeles, Chicago, or New York
//...
String choices[] = {"Los Angeles","Chicago","New York"};
choiceField = new ObjectChoiceField("select a city", choices);
add(choiceField);
Manager man = this.getMainManager();
}
...
public void paint(Graphics g){
super.paint(g);
// g.drawRect(0,left,500,500+left);
g.setGlobalAlpha(0);
g.drawRect(100-left,100-top,200,200);
String text = new Integer(left).toString();
String text2 = new Integer(top).toString();
g.drawText(text + " " + text2,120-left,120-top);
}
Hi I was wondering if someone could help me with this problem.
Thanks!!
Show how to use a stack S and a queue Q to generate all possible subsets of a set nonrecursively.
I use next code to print current time
Calendar cal = Calendar.getInstance();
System.out.println(cal.getTime());
I have Windows XP sp3 istalled. Current time in system tray is 14:30. But this code return 13:30
Why returned time is wrong?
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
private JPanel addressEntryPanel = new JPanel(new GridLayout(1,3));
private JPanel outputPanel = new JPanel(new GridLayout(1,1));
private JTextField serverTf = new JTextField("");
private JTextField pageTf = new JTextField("");
private JTextArea outputTa = new JTextArea();
private JButton connectBt = new JButton("Connect");
private JScrollPane outputSp = new JScrollPane(outputTa);
public void init()
{
setSize(500,500);
setLayout(new GridLayout(3,1));
add(addressEntryPanel);
addressEntryPanel.add(serverTf);
addressEntryPanel.add(pageTf);
addressEntryPanel.add(connectBt);
addressEntryPanel.setPreferredSize(new Dimension(50,50));
addressEntryPanel.setMaximumSize(addressEntryPanel.getPreferredSize());
addressEntryPanel.setMinimumSize(addressEntryPanel.getPreferredSize());
add(outputPanel);
outputPanel.add(outputSp);
outputTa.setLineWrap(true);
connectBt.addActionListener(this);
The problem is when debugging and putting it in a page the components / panels resize depending on the applet size. I don't want this. I want the textfields to be a certain size, and the text area to be a certain size. I've put stuff in there to set the size of them but they aren't working. How do I go about actually setting a strict size for either the components or the JPanel.