I am getting tyhis error while compiling
on terminal window
java.lang.OutOfMemoryError
My Comp config is
2.28 ghz
256 mb ram
512kb L2
Do i need to upgrade
i use blue j 2.1.3
i hv attached the file
Printable View
I am getting tyhis error while compiling
on terminal window
java.lang.OutOfMemoryError
My Comp config is
2.28 ghz
256 mb ram
512kb L2
Do i need to upgrade
i use blue j 2.1.3
i hv attached the file
And where is it (file)? :)
could not upload sorry :oQuote:
Originally Posted by Uladzimir
ill try
but plzz help me instead keeping jokes apart :cool:
Hi!
It might occurs in many cases. For example when you create an object in the infinite loop.
PS: Without sources impossible to say where the bug.
Quote:
Originally Posted by Uladzimir
Heres My code
Ill put two classes help on how to interconnect
Class1-
public class Library
{
String m[][] = new String [4][4];
String t[][] = new String [1][4];
public Library()
{
String t[][] = {{"Name"," Author"," Genre"," Published"},};
String m[][] = {
{"Psalm Of Life"," John Keats"," Religios"," Sun"},
{"Daffodils"," Willium"," Nature"," Sun"},
{"Julius Caesar"," Willium Shakespear"," Drama"," Morning Star"},
{"Merchant Of Venice"," Willium Sakespeare"," Romantic Drama"," Morning Star"},
};
for(int row = 0 ; row<m.length ; row++)
{
for(int col = 0 ; col < m[0].length ; col++)
{
System.out.print(m[row][col]);
}
System.out.println();
}
System.out.println(m.length + " " + m[0].length);
}}
Class2-
import java.io.*;
public class Borrow
{
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader br = new BufferedReader(isr);
public void bookDetails()throws IOException
{
String t[][] = {{"Name"," Author"," Genre"," Published"},};
String m[][] = {
{"Psalm Of Life"," John Keats"," Religios"," Sun "},
{"Daffodils"," Willium"," Nature"," Sun "},
{"Julius Caesar"," Willium Shakespeare"," Drama"," Morning Star"},
{"Merchant Of Venice"," Willium Sakespeare"," Romantic Drama"," Morning Star"},
};
for(int row = 0 ; row<m.length ; row++)
{
for(int col = 0 ; col < m[0].length ; col++)
{
System.out.print(m[row][col]);
}
System.out.println();
}}
public void option()throws IOException
{
int a = 0;
boolean flag = false;
System.out.print(" 1. Want to borrow a book??");
System.out.print(" 2. Go Back ");
System.out.print(" Please enter the number corresponding your choice ");
String temp = br.readLine();
do{
try
{
flag = false;
a = Integer.parseInt(temp);
System.out.print(" Please enter the number corresponding your choice ");
}
catch (NumberFormatException e)
{
System.out.print(" You have entered an invalid character ");
flag = true;
}}while(flag);
if(a!=1 || a!=2)
{
System.out.print(" Please enter the number corresponding your choice from the optoins given only ");
option();
}
else
if(a == 1)
bookDetails();
}}
I get tht error while compiling class 2 and tht is just 25% of the code i hv to actually write
Works for me... Try to add following parameters to java compiler
-Xms256M -Xmx256M
Thnx but noe there is another problem
Whwen i cr8 the object it goes into an infinite loop even when i enter correct values plzz check and reply thnx?
Hi!
1) Compile and runtime errors are not the same :)
2) Please add main method. What I should launch?
How do you add this and where can i find a java compilerQuote:
Originally Posted by Uladzimir
I am a beginner and am learning java because i hv to do it for my boards so i realy have no idea of anything outside my syllabus
Please provide steps on how to resolve the porblem
Quote:
Originally Posted by Uladzimir
I hvnt finish writing the complete code
Class 1 will contain main method from where you can login
Code for login only--
public void login()throws IOException
{
System.out.println("Enter Username");
String userName = br.readLine();
System.out.println("Enter password");
String psswrd = br.readLine();
userName.trim();
psswrd.trim();
boolean check = true;
int a = userName.length();
int b = psswrd.length() ;
String temp = "";
if (a == b)
for(int i = b-1; i>=0 ; i--)
{
temp = temp+psswrd.charAt(i);
}
System.out.println(temp);
if(userName.equalsIgnoreCase(temp))
System.out.println("Password Accepted. Thank You For Logging in "+userName);
else
{
System.out.println("You have entered an invalid password.Please call method again and re-enter your details.");
System.out.println("Password Forgotten?? -- Contact System Administrator at sa@library.org");
}
How can i make this method static???Code:Please help!!
1. >> How do you add this and where can i find a java compiler..
What IDE are you using?
2.
userName.trim(); // illegal; this line do nothing
userName = userName.trim(); // correct
3. >> How can i make this method static???
public static void login() throws IOException {
But as I understand compiler can't see "br" varable?!!
If yes then change your code to
static InputStreamReader isr = new InputStreamReader(System.in);
static BufferedReader br = new BufferedReader(isr);
BWT why are you and other students like to use static methods? This is not good approach.Very rare method should be a static. The overuse of static members can lead to problems similar to those experienced in languages like C and C++ that support global variables and global functions.