-
Some compiling Error
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)?
-
-
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.
-
 Originally Posted by Uladzimir
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.
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?
-
 Originally Posted by Uladzimir
Works for me... Try to add following parameters to java compiler
-Xms256M -Xmx256M
How do you add this and where can i find a java compiler
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
-
Hi!
1) Compile and runtime errors are not the same 
2) Please add main method. What I should launch?
-
 Originally Posted by Uladzimir
Hi!
1) Compile and runtime errors are not the same 
2) Please add main method. What I should launch?
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???
-
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.
Similar Threads
-
By mesh2005 in forum .NET
Replies: 1
Last Post: 03-06-2006, 08:16 AM
-
By Martin in forum VB Classic
Replies: 22
Last Post: 12-03-2001, 03:53 AM
-
By Khalizan in forum VB Classic
Replies: 1
Last Post: 11-28-2001, 01:32 AM
-
Replies: 1
Last Post: 10-24-2000, 11:38 AM
-
By Tom Shreve in forum Enterprise
Replies: 0
Last Post: 04-07-2000, 09:19 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks