I made a java login screen for a console application, but I need it to allow the user to input ther wrong PIN only 3 times. After the user has entered ... |
I am thinking to build a VERY large Java class, is there any limit on the number of methods the Java class can have? Can it go into the millions of ... |
In Javascript, if we have the following code:
var j = 0;
for(i=0; i<j; i++){
//JS Code
}
In this code, on what factors the maximum value of variable j (that is the value ... |
Technically I'm not aware of there being a restriction, but I would be wary of writing bloated methods performing more than one task and running into several hundered lines. Always best practice to split something up into several smaller methods to avoid confusing code. Also makes it easier to track bugs IMO. |
Well, I guess you could use an object depending on how the parameters are related to one another. I'm sure others can give better advice on that. However, remember that as of JDK 1.5 you can use the 'varargs' feature to pass (almost) as many parameters as you like to a method and have them treated like an array. Of course, ... |
Do you mean you want a method which calculates number of days in the month? Here is a totally diffrent approach: public static final int JANUARY = . . . DECEMBER = . . ; . . . public int daysInMonth(int monthNumber, boolean isLeapYear) { if (monthNumber < JANUARY || monthNumber > DECEMBER) return 0; switch(monthNumber) { case FEBRUARY: return isLeapYear ... |
I don't know if there is a theoretical limit, but if there is, it wouldn't be very interesting to know. There certainly isn't a practical limit. In real life, you should never write classes that are so big that the compiler can't handle them - because if the compiler can't, then the programmer certainly can't. |
|
I have a theoretical question, what is the maximum number of parameters to be passed is considered a good practice. In my method i am passing 5 parameters. I am moving forward to add more, so total will be 7 parameters. Well i have a solution to this problem. To make a Map and put 3 parameters inside it. and pass ... |
|
I would like to generate a function (unless one is already available), that computes the minimum and maximum values that can be generated by a random number generating formula: /** * This program generates 5 random numbers and lists them. */ import java.math.*; import java.util.*; import java.lang.Math.*; /** * @author Jon * */ public class Test { public static void main(String[] ... |
Hi, I've created a program and it seems to find the maximum value when a number of command line arguments are entered but i cannot get it to also print the index of which value it is: for (int i=0; i < args.length; i++) { double aValue = Double.parseDouble(args[i]); if (aValue > max) { max = aValue; largestIndex = i; } ... |
So I am new to programming and I am sorry if I am posting this is the wrong spot also. :o Hopefully someone will be able to help me figure out my problem! My problem is that I do not know how to find the minimum and maximum of 'n' numbers using and array or loop. The program is supposed to ... |
Do you have compilation errors or are you getting the wrong output? I could guess, but you need to learn to describe your problem better than "It's getting errors. What do I do?" Your maximum(...) method should return a primitive double, not a Double, but that's not your problem (autoboxing will occur, which you probably don't even realize). |
Hi I am working on an application where I am generating a excel spreadsheet using HSSF. I got an issue when I was told that maximum number of records might exceed 70,000. But Excel supports only 64556 (approx) rows. How can I overcome this. Idea in my mind is, I will generate a separate sheet when number of records exceed maximum ... |
I'd expect classes to be stored in memory in a HashMap or something similar, indexed by classname. Package name at the moment is not used as an index anywhere (it's just an identifier), though that is likely to change with the planned introduction of superpackages in Java 7 which will introduce true package hierarchies. This would suggest there to be a ... |