What a great connection between Hamlet and The Catcher in the Rye. Both characters have been disappointed by life and those around them. They lack a basic trust of human nature and don't even seem to have a good sense of themselves. I might pursue this idea further as I love both pieces of literature.
Hamlet is probably one of the most pessimistic characters around! The play starts with his pessimistic attitude toward his uncle, Claudius the new king and now his step-father (ugh). He is appalled by what he sees has the decay of the kingdom and even contemplates suicide, but God's laws don't allow it. Hamlet is even more pessimistic when he learns that his father, King Hamlet was murdered by his uncle, King Claudius. He spends a good deal of the play chiding himself for his inability to act in the name of revenge against Claudius. He calls himself "a rogue and peasant slave" at the end of Act 2. When his friends, Rosencrantz and Guildenstern, arrive he quickly become suspicious of their motives and states, pessimistically, that "Denmark is a prison." He is even rather pessimistic at the end of the play. He seems determined to see the revenge through, but says, "there is a divinity that shapes our ends rough hew them as we will." He believes that personal choice and fate work together, and while that may be true, it still feels pessimistic to me.
The Catcher in the Rye this one has been discussed already.
Catch-22 --the main character is always depressed that no matter how hard he tries or other try to do the right thing, circumstances are twisted to an unfortunate end.
Frankenstein--Victor is pessimistic about the creature, his whereabouts, and the future of the human race, even after he has dedicated his life to correcting the problem Victor set out on the world.
The Metamorphosis--Gregor is morphed because of his depression and negative attitude toward his family (they ride on his coattails without appreciating all he does). Afterward, their reaction to him as an insect of some kind are mixes of disgust, worry, and eventually hatred. As a result, he dies and they all suddenly become self-sufficient.
Another novel in which the main character demonstrates pessimism is Thomas Hardy's Tess of the D'Ubervilles. The tragic protagonist, Tess, becomes pessimistic about her future after Chance causes a freak-accident in which her family's horse and source of her father's livelihood is killed. Feeling responsible for this predicament, Tess agrees to seek the financial aid of the wealthy D'Ubervilles. However, when she encounters Alec D'Uberville, who is not really related to her, she is seduced and raped by him. Bereft and pregnant, she returns home. Tess obtains work as a farm hand and carries the baby to her work site. Weak, the baby dies and Tess is in despair, but seeks work as a dairymaid where she meets and falls in love with Angel Clare. However, she resists his proposals because of her feelings of unworthiness.
After she finally relents and agrees to wed Angel, Tess reveals her past; Angel cannot love the woman who does fit the image he has created. So, he departs England for Brazil and the poor Tess returns home. Again, she becomes a farm laborer, and in a chance occurrence, meets Alec D'Uberville with whom she goes since she and her family are starving. To add to her desperation, Angel returns to England, and, after having acquired experience, he forgives Tess. But, poor Tess is now with Alec, whom she stabs in her gloom. Fleeing with the loving Angel, Tess becomes exhausted and is apprehended. Later, she is executed for the murder she has committed, a fate she accepts in her deeply pessimistic state.
There will be many instances of works where the protagonist displays a healthy dose of pessimism. Holden Caulfield, in A Catcher in the Rye, is a main character who holds a healthy dose of skepticism and pessimism about traditionalist societies and the in-authenticity that accompanies it. In Flaubert's Madame Bovary, the character who "triumphs" in the end is the pharmacist Homais, who holds a great deal of pessimism about traditional notions of dreams and expectations and displays passion only about rationality and science. In the end of the book, he is the only one who represents some notion of success. In Wiesel's "Night," Eliezer represents a protagonist who displays a sense of pessimism and repudiation about the nature of a benevolent God who would permit the slaughtering of innocent babies and mothers at Auschwitz.