English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

this is the error

C:\bbs>javac libmainsys.java
libmainsys.java:43: array required, but int found
ypub[nElems] = new libary(title, author, ypub);
^
1 error

C:\bbs>

// to run this program: C>java libmainsys
////////////////////////////////////////////////////////////////
class libary
{
private String booktitle;
private String bookauthor;
private int yearpub;
//-----------------------------------------------------------
public libary(String title, String author, int ypub)
{ // constructor
booktitle = title;
bookauthor = author;
yearpub = ypub;
}
//-----------------------------------------------------------
public void displaylibary()
{
System.out.print(" Book Title: " + booktitle);
System.out.print(", Book Author: " + bookauthor);
System.out.println(",Year Publisher : " + yearpub);
}

public String getLast() // get title
{ return booktitle; }
} // end class libary

2007-01-22 02:21:04 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

class ArrayInOb
{
private libary[] ypub; // ref to array ypub
private int nElems; // number of data items
//--------------------------------------------------------------
public ArrayInOb(int max) // constructor
{
ypub = new libary[max]; // create the array
nElems = 0; // no items yet
}
//--------------------------------------------------------------
// put libary into array
public void insert(String title, String author, int ypub)
{
ypub[nElems] = new libary(title, author, ypub);
nElems++; // increment size
}
//--------------------------------------------------------------
public void display() // displays array contents
{
for(int j=0; j ypub[j].displaylibary(); // display it
System.out.println("");
}

2007-01-22 02:21:54 · update #1

public void insertionSort()
{
int in, out;

for(out=1; out {
libary temp = ypub[out]; // remove marked person
in = out; // start shifting at out

while(in>0 && // until smaller one found,
ypub[in-1].getLast().compareTo(temp.getLast())>0)
{
ypub[in] = ypub[in-1]; // shift item to the right
--in; // go left one position
}
ypub[in] = temp; // insert marked item
} // end for
} // end insertionSort()

} // end class ArrayInOb
////////////////////////////////////////////////////////////////
class libmainsys
{
public static void main(String[] args)
{
int maxSize = 1000; // array size
ArrayInOb arr; // reference to array
arr = new ArrayInOb(maxSize); // create the array

2007-01-22 02:22:40 · update #2

arr.insert("Java_how__to_program", "Patty", 2001);
arr.insert("System_Design", "Doc", 2002);
arr.insert("Program_Design", "Lorraine", 1999);
arr.insert("Computer_Architecture", "Paul", 2006);
arr.insert("Visual_Basic_How_To_ Program", "Tom", 2007);
arr.insert("Information_ Management", "Sato", 1995);
arr.insert("Sofware_ Application", "Henry", 1996);
arr.insert("English", "Jose", 1994);
arr.insert("Web_Publishing", "Minh", 1993);
arr.insert("Human_Computer_Interaction", "Lucinda", 2002);

System.out.println("Before sorting:");
arr.display(); // display items

arr.insertionSort(); // insertion-sort them

System.out.println("After sorting:");
arr.display(); // display them again
} // end main()
} // end class libmainsys

2007-01-22 02:23:02 · update #3

2 answers

In these lines
// put libary into array
public void insert(String title, String author, int ypub)
{
ypub[nElems] = new libary(title, author, ypub);
nElems++; // increment size

how can you have the same name on an array on the left side and an integer inside the parans on the right side?

2007-01-22 03:10:25 · answer #1 · answered by Mike1942f 7 · 0 0

There may well be a malicious application. the will arises to evaluate a gadget fix to the earliest date then delete each and each and each and all of the previous gadget fix dates. the will arises to maintain important stuff. additionally the will arises to comb up on the thank you to prepare the living house living house windows record gadget(each and each and each and all of the learning and manipulations on the keyboard. that's that in case you do no longer desire to play around with Java. If this would not artwork the will arises to reinstall living house living house windows. Or in case you desire to repair Java you're able to could desire to purchase application(no longer my suggestion). you're able to desire to do additionally delete pointless popups and junk that upward push up on a daily basis. have you ever acknowledged into Linux Ubuntu or Mint for Java?

2016-11-26 01:58:51 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers