RMI :: 127.0.1.1 Nested Exception
Apr 4, 2013
I was trying to contact many servers. The lookup was successful, but the procedure call caused the error:
java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:
* java.net.ConnectException: Connexion refusée*
What would cause this error during the call.
View Replies
ADVERTISEMENT
Jan 24, 2014
I was giving a quick skim to some tutorials on the internet where I have found the exception that is handled is also declared in the throws clause of the method wrapping the try-catch block. For a code representation consider the following:
public void methodName() throws IOException {
try {
...
} catch (IOException ex) {
.... TODO handle exception
}
}
View Replies
View Related
Sep 29, 2014
Right, so I got this program. It takes input from the user and assigns it to fields on an object. But, it's meant to check the users input. If the user enters bad input, it's supposed to throw this exception. For each of these exceptions, theres a class specifically for it.
public class PayrollDemo
{
public static void main(String[] args)
{
Payroll pr = new Payroll ("Test Name", 234);
System.out.println("Current Employee Information.
");
System.out.println("Name: " + pr.getName());
System.out.println("ID: " + pr.getID());
System.out.println("Hourly Pay Rate: " + pr.getHourlyPayRate());
[Code] ....
And this is the exception class.
public class InvalidNameException extends Exception
{
/**
No-arg constructor
*/
public InvalidNameException()
{
super("Invalid name");
}
}
PayrollDemo.java:43: error: cannot find symbol
InvalidNameException.InvalidNameException();
^
symbol: method InvalidNameException()
location: class InvalidNameException
1 error
It's just meant to tell the user that they entered an invalid value, which would mean if they entered an empty string instead of a name.
View Replies
View Related
Sep 11, 2014
I am in the process of creating a calculator GUI that calculates different answers based on inputs two main comboboxes and numbers in the appropriate textfields. The first one allows the user to choose from 18 different materials, while the second has the user choose between two different shapes. In a brief word explanation, here's how it's set up:
User chooses material.
User chooses shape.
User types in appropriate values.
'Calculate' button clicked.
If shape = rectangle, execute rectangle calculation.
Else if shape = cylinder, execute cylinder calculation.
Everything works just fine with zero errors on all 18 materials and all kinds of decimal numbers when the second shape is selected. So the math and layout is solid. However, when the first shape is selected, it returns a $0.00 answer regardless of the input values (still no red-line errors). In efforts to troubleshoot, when I have /* Cylinder section */, the rectangle section works to a 'T'. This, I believe is caused by poor formatting in the syntax of the 'if' 'else if' in regards to the shape combobox.
//If 'Rectangle' is selected:
if(shapeDropDown.getSelectedIndex()==1) {
//6061
if(materialDropDown.getSelectedIndex()==0) {
String msg0 = "The price is: $"
+ currencyFormat.format((0.098*(number2*number3*number4)*3.06));
totalPrice.setText(msg0);
[code]....
View Replies
View Related
Apr 5, 2014
just trying to learn it on my spare time and I'm doing do-while loops
public class help {
public static void main (String args[])
throws java.io.IOException {
char choice, ignore;
do{
System.out.println ("Choose one:");
System.out.println("1. if");
System.out.println("2.switch");
[code]....
It makes no difference in the program wither i delete this block or keep it..how while (choice < '1'| choice >'2'); translates? I would assume it would be while (choice >= '1'| choice =<'2');?
View Replies
View Related
Dec 17, 2013
Question: you are only allowed to use numbers from 1-6. Write a program to find all the permutations when three numbers are multiplied together to give a result 8. one number cannot occur twice in any permutation.
public class number4
{ public static void main(String[] args)
{
for(int a=1; a<=4; a++)
{
for(int b=1; b<=4; b++)
{
[Code]...
my program also prints out 2 2 2. but i'm not allowed to do that. how can I stop it from printing 2 2 2 ?
View Replies
View Related
May 15, 2014
how a nested for loop increments the outer loop and then the inner loop and then when it runs the inside code.I've ran the program a few times but I'm just not understanding it, need little narrative to it?
for(int i=0; i < 5; i++){
System.out.println("i - " + i);
for(int j=0; j < i; j++){
System.out.println("j - " + j);
count++;
}
}
View Replies
View Related
Oct 6, 2014
write a program using nested switch case to show the different shops in a shopping mall.
View Replies
View Related
Mar 6, 2015
Here's what "Why doesn't this work?" question. It concerns a small method which is part of a card game.
I'm trying to check a condition from a section of an array, without a predetermined number of times any given call to this method will require a check. How much of the array I'm checking could vary greatly.
Is it at all possible to nest a for loop yielding a variable number of boolean && conditions inside an if? Am I just missing the right bracketing or is this nesting (if that's the word) even possible in the language?
To clarify, below is broken code. Compiler isn't letting me accomplish this goal as I envision it.
public boolean isFlanking() {
boolean f;
int reach = Math.abs(selectorX - targetX);
if(rival.getDeck()[selectorX].getPile().isEmpty() == true &&
[Code] ....
View Replies
View Related
Apr 11, 2014
Need to create a nested table without using datatable. I am using jsp and jsf but using datatable is not allowed.
View Replies
View Related
May 21, 2014
//Main method
public static void main(String args[])throws IOException{
boolean runProgram = true;
Scanner keyboard = new Scanner(System.in);
//runs program while runProgram is true
while (runProgram){
[code].....
View Replies
View Related
Oct 12, 2014
int count = 0;
for (int x = 0; x < 3; x++)
for (int y = x; y < 3; y++)
for (int z = y; z < 3; z++)count++;
What is the value of count after the code segment is executed?
The answer is 9, but I don't really understand how this answer was derived.
View Replies
View Related
Feb 8, 2015
i'm trying to do a nested circle dynamically. i don't know whats wrong with my program ...
private Ellipse2D.Float doubleElip(int x1, int y1, int x2, int y2){
int x = Math.min(x1, x2);
int y = Math.min(y1, y2);
int width = Math.abs(x1 - x2);
int height = Math.abs(y1 - y2);
for( int i=0; i < 1; i++){
Ellipse2D.Float elip = new Ellipse2D.Float(x , y,
width/i, height/i);
}
return elip;
}
View Replies
View Related
Nov 17, 2014
I want to ask a user his name. If he writes John, then program should answer "John is your first name." Is he writes Smith, the program should say "Smith is your last name." If user writes anything else, such as Sue, the program should state "This is not your name."
How to ask user input and also how to work with the nested if-else statement. For some reason I do not understand, my code always results in "This is not your name" even if user writes John or Smith.
import java.util.*;
public class NestedIfElse{
public static void main(String args[]) {
String name;
Scanner reader = new Scanner(System.in);
System.out.println("What is your name?");
[Code] ....
View Replies
View Related
Nov 5, 2014
for (int i = 0; i < 4; i++)
{
for (int k = 0; k < i; k++)
{
System.out.print(" ");
}
for (int j = 4; j > i; j--)
{
System.out.print("$");
}
System.out.println();
}
I was told that the answer when this code segment is printed look's like this:
$$$$
$$$
$$
$
Here's what I did:Looking at the outer for loop, (i) 0 < 4 so I went into the first inner nested loop. (k) 0 is not less than (i) 0 so I went to the 2nd inner nested loop and found that it worked, and I was able to repeat this loop 3 more times and then I exited the loop and printed the line out (giving me the first line of four $). I then went back to the outer for loop, increased i by 1 and (i) 1 < 4 so I went to the 1st inner nested loop. I used the 0 for the k first and (k) 0 < 1 so I printed out a space (now here's where I get lost) I then incremented k by 1, so k = 1, but 1 is not less than 1 (i) and so I moved on to the next nested for loop. So when this line is printed, I'll only have one space when there should be 4.
View Replies
View Related
Feb 9, 2015
i want to use nested loops to print patterns but i cant seem to make a pattern that will look like V and K this should be the outcome.
* *
* *
* *
* *
*
@ @
@ @
@@
@ @
@ @
View Replies
View Related
Oct 10, 2013
Is there any advantage to using Java's operations defined in sets or collections over inspecting in nested for-loops?
For example, suppose I want to keep items from one array that do not appear in another, I could do:
for( PrimitiveType prim_1 : someArray ){
for( PrimitiveType prim_2 : otherArray ){
if( prim_1 != prim_2){
///put in some return list
}
}
}
Or else I could do:
ArrayList<NotPrimitive> excludedElements =
new ArrayList(Arrays.asList(primitiveArrayToExclude));
for( PrimitiveType elem : someArray){
if( ! excludedElements.contains( elem ) {
//put in some return list
}
}
I personally see no improvement in legibility nor any reduction of error potential.....
View Replies
View Related
Oct 12, 2014
int count = 0;
for (int x = 0; x < 3; x++)
for (int y = x; y < 3; y++)
for (int z = y; z < 3; z++)
count++;
What is the value of count after the code segment is executed?
The answer is 9, but I don't really understand how this answer was derived.
View Replies
View Related
May 20, 2014
I'm having trouble figuring out the Big-O notation for this loop. For now I only have it in pseudocode. I hope you understand it anyway
for i = 1 to n do
j = 1
while j <= n/2 do
print "*"
j = j + 1
end while
end for
View Replies
View Related
Mar 5, 2015
i want to draw a circle inside a circle in java. so far i'm using this piece of code
private Ellipse2D.Float drawEllipse(int x1, int y1, int x2, int y2) {
int x = Math.min(x1, x2);
int y = Math.min(y1, y2);
int width = Math.abs(x1 - x2);
int height = Math.abs(y1 - y2);
return new Ellipse2D.Float(x, y, width, height);
}
View Replies
View Related
Aug 19, 2014
I have an XML document that have multiple levels of nesting:
<virtue name="Innocence">
<rank ranklvl="1">
<stat type="Physical Mitigation" value="84" />
<stat type="Resistance Rating" value="89" />
<stat type="Tactical Mitigation" value="29" />
</rank>
<rank ranklvl="2">
[Code] ....
I need to return all the different values within each child element... i.e.
Virtue: Innocence
Rank: 1
Physical Mitigation = 84
Physical Rating = 89
Tactical Mitigation = 29
Virtue: Innocence
Rank: 2
Physical Mitigation = 162
Physical Rating = 175
Tactical Mitigation = 54
I can read the XML okay but I get an error on displaying the information.
for (int temp = 0; temp < nList.getLength(); temp++) {
//Node nNode = nList.item(temp);
Node nNode = nList.item(temp);
//System.out.println("
Current Virtue :" + nNode.getNodeName());
[Code] ....
View Replies
View Related
Jan 24, 2015
Write a program that will display the following pattern.
$$$$$$$$$$
$$$$$$$$$
$$$$$$$$
$$$$$$$
$$$$$$
$$$$$
$$$$
$$$
$$
$
I need to write a program that uses nested for loops to display that patter but I have no clue on how to do it....
View Replies
View Related
Feb 13, 2014
I don't know how to write a program based on for loop like pattern printing.etc
View Replies
View Related
Sep 21, 2014
I am having a problem understanding line spacing. I need to write a program that has nested FOR LOOPS to produce the following output:
1
2
3
4
5
I can get a for loop that counts down. The problem I have is using for loop for line spacing. How a for loop for a line works.
View Replies
View Related
Jan 5, 2015
The title says already where my difficulties are. I forgot to say, the "S" printing part works, but why the others doesn't. To make it more clear:
java Monoton 1 3 3 4 & java Monoton 1 3 4 1
=> nothing (my output)
I forgot to notice, with 1 3 3 4 as parameters it jumps out at if (b < c), which is expected. but it jumps out of the whole if instead just run the else part. that's the essence of my problem.
The Exercise:
=> The program should print the following letters;
S, if every number is true bigger than the before,
M, if every number is bigger or equal than the before,
N in the other cases
Examples (from the exercise)
=> java Monoton 0 1 2 4
S
=> java Monoton 1 3 3 4
M
=> java Monoton 1 3 4 1
N
The Exercise should done without the use of logical operators or other combined requirements.
Java Code:
public class Main {
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
int d = Integer.parseInt(args[3]);
[Code] .....
View Replies
View Related
Sep 27, 2014
how does this nested enhanced for loop execute? I dont know how to indent the code.
for (String exam : exams)
for (String level : levels)
for (String grade : grades)
System.out.println(exam+":"+level+":"+grade);
Note:
exams,levels,grades are arraylist
exams contain Java,Oracle
levels contain Basic,Advanced
grades contain pass,fail
View Replies
View Related